Verified Commit b22c7076 authored by Moed, Matthijs's avatar Moed, Matthijs
Browse files

Remove scratch directory completely, not just its files. See !95.

parent 0e28ebc2
Pipeline #57599 passed with stage
in 43 seconds
......@@ -2148,6 +2148,9 @@ public class GenomeLayer {
System.err.println("Error occurred during localization: " + e);
e.printStackTrace(System.err);
System.exit(1);
} finally {
if (!keepIntermediateFiles)
deleteDirectoryRecursively(scratchDirectory);
}
try (Transaction tx = GRAPH_DB.beginTx()) {
......@@ -2215,7 +2218,8 @@ public class GenomeLayer {
add_sequence_properties(scratchDirectory);
localize_nodes();
genome_overview();
deleteDirectoryRecursively(scratchDirectory);
System.out.println("\rNumber of kmers: " + indexSc.length());
System.out.println("Number of nodes: " + num_nodes);
System.out.println("Number of edges: " + num_edges);
......@@ -3457,4 +3461,18 @@ public class GenomeLayer {
}
return directory;
}
/**
* Delete a directory and its contents.
* @param directory path to directory.
*/
public void deleteDirectoryRecursively(Path directory) throws IOException {
try (Stream<Path> paths = Files.walk(directory)) {
//noinspection ResultOfMethodCallIgnored
paths
.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(File::delete);
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment