Github user afs commented on a diff in the pull request:
https://github.com/apache/jena/pull/459#discussion_r209542012
--- Diff:
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
---
@@ -288,28 +294,77 @@ protected void execDeleteItem(HttpAction action) {
if ( ! action.getDataAccessPointRegistry().isRegistered(name) )
ServletOps.errorNotFound("No such dataset registered: "+name);
+ // This acts as a lock.
systemDSG.begin(ReadWrite.WRITE) ;
boolean committed = false ;
+
try {
// Here, go offline.
// Need to reference count operations when they drop to zero
// or a timer goes off, we delete the dataset.
DataAccessPoint ref =
action.getDataAccessPointRegistry().get(name) ;
+
// Redo check inside transaction.
if ( ref == null )
ServletOps.errorNotFound("No such dataset registered:
"+name);
+
+ String filename = name.startsWith("/") ? name.substring(1) :
name;
+ List<String> configurationFiles =
FusekiSystem.existingConfigurationFile(filename);
+ if ( configurationFiles.size() != 1 ) {
+ // This should not happen.
+ action.log.warn(format("[%d] There are %d configuration
files, not one.", action.id, configurationFiles.size()));
+ ServletOps.errorOccurred(
+ format(
+ "There are %d configuration files, not one. Delete
not performed; clearup of the filesystem needed.",
+ action.id, configurationFiles.size()));
+ }
+
+ String cfgPathname = configurationFiles.get(0);
+
+ // Delete configuration file.
+ // Once deleted, server restart will not have the database.
+ FileOps.deleteSilent(cfgPathname);
- // Make it invisible to the outside.
+ // Get before removing.
+ DataService dataService = ref.getDataService();
+
+ // Make it invisible in this running server.
action.getDataAccessPointRegistry().remove(name);
- // Delete configuration file.
- // Should be only one, undo damage if multiple.
- String filename = name.startsWith("/") ? name.substring(1) :
name;
-
FusekiSystem.existingConfigurationFile(filename).stream().forEach(FileOps::deleteSilent);
- // Leave the database in place. if it is in /databases/,
recreating the
- // configuration will make the database reappear. This is
intentional.
- // Deleting a large database by accident is a major mistake.
+ // Delete the database for real only when it is in the server
"run/databases"
+ // area. Don't delete databases that reside elsewhere. We do
delete the
+ // configuration file, so the databases will not be associated
with the server
+ // anymore.
--- End diff --
The config file is deleted with (line 327):
```
FileOps.deleteSilent(cfgPathname);
```
and this code line 351) looks for the direct in the "run/databases" area
which is `FusekiSystem.dirDatabases`:
```
Path pDatabase =
FusekiSystem.dirDatabases.resolve(filename);
if ( Files.exists(pDatabase)) {
try {
if ( Files.isSymbolicLink(pDatabase)) {
```
---