diff --git a/backend/src/main/java/cz/cuni/mff/xrg/odcs/backend/execution/pipeline/impl/CleanUp.java b/backend/src/main/java/cz/cuni/mff/xrg/odcs/backend/execution/pipeline/impl/CleanUp.java index ea382b653f..e28f1e5dd1 100644 --- a/backend/src/main/java/cz/cuni/mff/xrg/odcs/backend/execution/pipeline/impl/CleanUp.java +++ b/backend/src/main/java/cz/cuni/mff/xrg/odcs/backend/execution/pipeline/impl/CleanUp.java @@ -61,6 +61,13 @@ public boolean postAction(PipelineExecution execution, Map contexts, DependencyGraph graph) { LOG.debug("CleanUp start .. "); + + try { + this.relationalRepositoryManager.release(execution.getContext().getExecutionId()); + } catch (Exception e) { + LOG.error("Failed to release relational repository", e); + } + // first release contexts for (Context item : contexts.values()) { if (execution.isDebugging()) { @@ -93,12 +100,6 @@ public boolean postAction(PipelineExecution execution, } } - try { - this.relationalRepositoryManager.release(execution.getContext().getExecutionId()); - } catch (Exception e) { - LOG.error("Failed to release relational repository", e); - } - // prepare execution root File rootDir = new File( appConfig.getString(ConfigProperty.GENERAL_WORKINGDIR)); diff --git a/dataunit-relational-impl/src/main/java/eu/unifiedviews/dataunit/relational/repository/FilesRelationalDatabase.java b/dataunit-relational-impl/src/main/java/eu/unifiedviews/dataunit/relational/repository/FilesRelationalDatabase.java index e344d8efd6..713b6c9c7d 100644 --- a/dataunit-relational-impl/src/main/java/eu/unifiedviews/dataunit/relational/repository/FilesRelationalDatabase.java +++ b/dataunit-relational-impl/src/main/java/eu/unifiedviews/dataunit/relational/repository/FilesRelationalDatabase.java @@ -127,12 +127,17 @@ public void release() throws Exception { private void deleteDatabaseFile() throws IOException { Pattern filesPattern = Pattern.compile(this.databaseFileName + ".*"); + if (this.dataunitDirectory == null || !this.dataunitDirectory.exists()) { + return; + } File[] filesInDataUnitDir = this.dataunitDirectory.listFiles(); + if (filesInDataUnitDir == null) { + return; + } for (File file : filesInDataUnitDir) { if (filesPattern.matcher(file.getName()).matches()) { Files.delete(file.toPath()); } - break; } }