mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
NPE check for parentFile and better name
This commit is contained in:
+3
-3
@@ -44,7 +44,7 @@ import java.io.*;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import static com.intellij.util.io.IOUtil.deleteWithSubordinates;
|
||||
import static com.intellij.util.io.IOUtil.deleteAllFilesStartingWith;
|
||||
|
||||
@SuppressWarnings({"PointlessArithmeticExpression", "HardCodedStringLiteral"})
|
||||
public class FSRecords implements Forceable {
|
||||
@@ -237,10 +237,10 @@ public class FSRecords implements Forceable {
|
||||
closeFiles();
|
||||
|
||||
boolean deleted = FileUtil.delete(getCorruptionMarkerFile());
|
||||
deleted &= deleteWithSubordinates(namesFile);
|
||||
deleted &= deleteAllFilesStartingWith(namesFile);
|
||||
deleted &= AbstractStorage.deleteFiles(attributesFile.getCanonicalPath());
|
||||
deleted &= AbstractStorage.deleteFiles(contentsFile.getCanonicalPath());
|
||||
deleted &= deleteWithSubordinates(recordsFile);
|
||||
deleted &= deleteAllFilesStartingWith(recordsFile);
|
||||
|
||||
if (!deleted) {
|
||||
throw new IOException("Cannot delete filesystem storage files");
|
||||
|
||||
@@ -134,14 +134,15 @@ public class IOUtil {
|
||||
return c < 128;
|
||||
}
|
||||
|
||||
public static boolean deleteWithSubordinates(File file) {
|
||||
public static boolean deleteAllFilesStartingWith(File file) {
|
||||
final String baseName = file.getName();
|
||||
final File[] files = file.getParentFile().listFiles(new FileFilter() {
|
||||
File parentFile = file.getParentFile();
|
||||
final File[] files = parentFile != null ? parentFile.listFiles(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(final File pathname) {
|
||||
return pathname.getName().startsWith(baseName);
|
||||
}
|
||||
});
|
||||
}): null;
|
||||
|
||||
boolean ok = true;
|
||||
if (files != null) {
|
||||
|
||||
@@ -284,7 +284,7 @@ public class PersistentHashMap<Key, Value> extends PersistentEnumeratorDelegate<
|
||||
}
|
||||
|
||||
public static void deleteFilesStartingWith(@NotNull File prefixFile) {
|
||||
IOUtil.deleteWithSubordinates(prefixFile);
|
||||
IOUtil.deleteAllFilesStartingWith(prefixFile);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user