Update isEmpty() to isMissingOrEmpty().
parent
3cc5f1cb1e
commit
51b6e359fd
|
@ -118,7 +118,7 @@ public class ImportWorker extends SwingWorker<Boolean, Void> {
|
|||
String directoryName = "stats";
|
||||
Path sourcePath = importDataPath.resolve(directoryName);
|
||||
Path targetPath = MagicFileSystem.getDataPath().resolve(directoryName);
|
||||
if (sourcePath.toFile().exists() && MagicFileSystem.isEmpty(targetPath)) {
|
||||
if (sourcePath.toFile().exists() && MagicFileSystem.isMissingOrEmpty(targetPath)) {
|
||||
IOFileFilter dbSuffixFilter = FileFilterUtils.suffixFileFilter(".db");
|
||||
FileUtils.copyDirectory(sourcePath.toFile(), targetPath.toFile(), dbSuffixFilter);
|
||||
}
|
||||
|
|
|
@ -312,7 +312,10 @@ public final class MagicFileSystem {
|
|||
return getDataPath(DataPath.LOGS).resolve(MagicGameLog.LOG_FILE);
|
||||
}
|
||||
|
||||
public static boolean isEmpty(Path path) throws IOException {
|
||||
public static boolean isMissingOrEmpty(Path path) throws IOException {
|
||||
if (!Files.exists(path)) {
|
||||
return true;
|
||||
}
|
||||
if (Files.isDirectory(path)) {
|
||||
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(path)) {
|
||||
return !dirStream.iterator().hasNext();
|
||||
|
|
Loading…
Reference in New Issue