X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fmigration%2FMigrationStateImpl.java;fp=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fmigration%2FMigrationStateImpl.java;h=3e531e368e512761cca1c4d8691d6d01c55cabc0;hb=d331e06e5825b124d5a76b1fdc1b45bbb5506407;hp=fb8f8c9e7aef04f1e93f1f087ed5c297fa9879f7;hpb=04220731a0cac3fe6fe2c3375a73d698e11d476f;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigrationStateImpl.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigrationStateImpl.java index fb8f8c9e7..3e531e368 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigrationStateImpl.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigrationStateImpl.java @@ -161,8 +161,16 @@ public class MigrationStateImpl implements MigrationState { final boolean updateDependencies = MigrationUtils.getProperty(this, MigrationStateKeys.UPDATE_DEPENDENCIES, Boolean.TRUE); File temporaryTg = exportCurrentTgAsTemporaryFile(session, monitor); - if (temporaryTg != null) - setProperty(MigrationStateKeys.CURRENT_TGS, initializeTransferableGraphSource(temporaryTg)); + if (temporaryTg != null) { + TransferableGraphSource tgs = (TransferableGraphSource)properties.get(MigrationStateKeys.CURRENT_TGS); + if (tgs != null) + try { + tgs.close(); + } catch (IOException e) { + Logger.defaultLogError(e); + } + setProperty(MigrationStateKeys.CURRENT_TGS, initializeTransferableGraphSource(temporaryTg, true)); + } TransferableGraphSource tgs = getProperty(MigrationStateKeys.CURRENT_TGS); if (tgs != null) { @@ -253,8 +261,11 @@ public class MigrationStateImpl implements MigrationState { } private TransferableGraphSource initializeTransferableGraphSource(File dataContainer) throws DatabaseException { + return initializeTransferableGraphSource(dataContainer, false); + } + private TransferableGraphSource initializeTransferableGraphSource(File dataContainer, boolean deleteOnClose) throws DatabaseException { try { - StreamingTransferableGraphFileReader reader = new StreamingTransferableGraphFileReader(dataContainer); + StreamingTransferableGraphFileReader reader = new StreamingTransferableGraphFileReader(dataContainer, deleteOnClose); TransferableGraphSource tgs = reader.readTG(); setProperty(MigrationStateKeys.CURRENT_TGS_READER, reader); setProperty(MigrationStateKeys.CURRENT_TGS, tgs);