Skip to content

Commit 7cf253b

Browse files
fix npe on empty backup folder (#186)
1 parent 4015f0f commit 7cf253b

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

DriveBackup/src/main/java/ratismal/drivebackup/util/FileUtil.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,12 @@ public TreeMap<Long, File> getLocalBackups(String location, LocalDateTimeFormatt
5151
TreeMap<Long, File> backupList = new TreeMap<>();
5252
String path = new File(ConfigParser.getConfig().backupStorage.localDirectory).getAbsolutePath() + "/" + location;
5353
File[] files = new File(path).listFiles();
54+
if (files == null) {
55+
return backupList;
56+
}
5457
for (File file : files) {
5558
if (file.getName().endsWith(".zip")) {
56-
//String fileName = file.getName();
57-
// try {
58-
// ZonedDateTime date = formatter.parse(fileName);
59-
// backupList.put(date.toEpochSecond(), file);
60-
// } catch (Exception e) {
61-
// Fallback to using file creation date if the file name doesn't match the format.
6259
backupList.put((file.lastModified() / 1000), file);
63-
// logger.log(intl("local-backup-date-format-invalid"), "file-name", fileName);
64-
// }
6560
}
6661
}
6762
return backupList;

0 commit comments

Comments
 (0)