Skip to content

Commit

Permalink
#266 #295 Clearing TDB folder instead of deleting it for ensuring win…
Browse files Browse the repository at this point in the history
…dows compatibility
  • Loading branch information
luigi-asprino committed Nov 14, 2023
1 parent bf69d24 commit 6e07a86
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.sparql.core.DatasetGraphFactory;
import org.apache.jena.tdb.TDBFactory;
import org.apache.jena.tdb2.DatabaseMgr;
import org.apache.jena.tdb2.TDB2Factory;
import org.slf4j.Logger;
Expand Down Expand Up @@ -59,7 +60,12 @@ private void initialiseDatasetGraph(Properties properties) {
try {
FileUtils.deleteDirectory(ondiskFile);
} catch (IOException e) {
throw new RuntimeException(e);
if (TDBFactory.inUseLocation(ondiskPath)) {
TDB2Factory.connectDataset(ondiskPath).asDatasetGraph().clear();
log.warn("Clearing TBD instead of deleting the TDB folder.");
} else {
throw new RuntimeException(e);
}
}
}
datasetGraph = TDB2Factory.connectDataset(ondiskPath).asDatasetGraph();
Expand Down

0 comments on commit 6e07a86

Please sign in to comment.