]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.utils/src/org/simantics/utils/FileUtils.java
Hardening of DB index integrity
[simantics/platform.git] / bundles / org.simantics.utils / src / org / simantics / utils / FileUtils.java
index b794c9360473a360d973ba5826a3d96eef942a62..4e68f29c4ac95246da7d81d2b9e14c7b323dafbc 100644 (file)
@@ -492,7 +492,7 @@ public class FileUtils {
                 }              
             }
         } else if (dir.exists()) {
-               if (filter.contains(dir.getAbsolutePath())) {
+               if (!filter.contains(dir.getAbsolutePath())) {
                 if (!dir.delete()) {
                     throw new IOException("Could not delete file: " + dir.getAbsolutePath());
                 }
@@ -1013,4 +1013,10 @@ public class FileUtils {
             return FileVisitResult.CONTINUE;
         }
     }
+    
+    public static void syncFile(File file) throws IOException {
+       try (RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
+               raf.getFD().sync();
+               }
+    }
 }