]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java
Worked around Windows FS problems in IndexedRelationsSearcherBase
[simantics/platform.git] / bundles / org.simantics.db.indexing / src / org / simantics / db / indexing / IndexedRelationsSearcherBase.java
index 136a7bcf643d689f1d5f7e6cc04206ea5aee001f..1d5001c64ec15f728cfee967f19d75dcc2123dbb 100644 (file)
@@ -624,7 +624,7 @@ abstract public class IndexedRelationsSearcherBase {
                     mon.subTask("Erasing previous index");
                     if (getLogger().isDebugEnabled())
                         getLogger().debug("Erasing previous index {}", indexPath.toAbsolutePath());
                     mon.subTask("Erasing previous index");
                     if (getLogger().isDebugEnabled())
                         getLogger().debug("Erasing previous index {}", indexPath.toAbsolutePath());
-                    FileUtils.delete(indexPath);
+                    FileUtils.emptyDirectory(indexPath);
                 }
             }
     
                 }
             }
     
@@ -633,7 +633,7 @@ abstract public class IndexedRelationsSearcherBase {
     
             try {
                 mon.subTask("Start index write");
     
             try {
                 mon.subTask("Start index write");
-                createDirectory(indexPath);
+                Files.createDirectories(indexPath);
     
                 directory.set(FSDirectory.open(indexPath.toFile()));
                 IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_4_9, Queries.getAnalyzer()).setOpenMode(OpenMode.CREATE);
     
                 directory.set(FSDirectory.open(indexPath.toFile()));
                 IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_4_9, Queries.getAnalyzer()).setOpenMode(OpenMode.CREATE);
@@ -992,20 +992,14 @@ abstract public class IndexedRelationsSearcherBase {
         return path;
     }
 
         return path;
     }
 
-    private static void createDirectory(Path path) throws IOException {
-        if (Files.exists(path) && !Files.isDirectory(path))
-            throw new IOException("Could not create index directory " + path + ", a file by that name already exists");
-        Files.createDirectories(path);
-    }
-
     Path getIndexPath() {
         return indexPath;
     }
 
     boolean isIndexAvailable() {
     Path getIndexPath() {
         return indexPath;
     }
 
     boolean isIndexAvailable() {
-        return (Files.exists(indexPath) && Files.isDirectory(indexPath));
+        return Files.isDirectory(indexPath);
     }
     }
-    
+
     abstract Throwable bestEffortClear(IProgressMonitor monitor, Session session);
 
     /*
     abstract Throwable bestEffortClear(IProgressMonitor monitor, Session session);
 
     /*