Trying to handle file name parsing error in backup engine
This commit is contained in:
parent
0d94361d38
commit
d11631a942
@ -2,6 +2,7 @@ package fr.pandacube.lib.paper.modules.backup;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
@ -80,7 +81,13 @@ public abstract class BackupCleaner implements UnaryOperator<TreeSet<LocalDateTi
|
|||||||
}
|
}
|
||||||
|
|
||||||
String dateTimeStr = filename.substring(0, filename.length() - 4);
|
String dateTimeStr = filename.substring(0, filename.length() - 4);
|
||||||
LocalDateTime ldt = LocalDateTime.parse(dateTimeStr, CompressProcess.dateFileNameFormatter);
|
LocalDateTime ldt;
|
||||||
|
try {
|
||||||
|
ldt = LocalDateTime.parse(dateTimeStr, CompressProcess.dateFileNameFormatter);
|
||||||
|
} catch (DateTimeParseException e) {
|
||||||
|
Log.warning("Unable to parse file name to a date-time: " + file, e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
datedFiles.put(ldt, file);
|
datedFiles.put(ldt, file);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import java.time.ZonedDateTime;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.DateTimeFormatterBuilder;
|
import java.time.format.DateTimeFormatterBuilder;
|
||||||
import java.time.temporal.ChronoField;
|
import java.time.temporal.ChronoField;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
|
|
||||||
@ -153,9 +152,11 @@ public abstract class CompressProcess implements Comparable<CompressProcess>, Ru
|
|||||||
|
|
||||||
|
|
||||||
static DateTimeFormatter dateFileNameFormatter = new DateTimeFormatterBuilder()
|
static DateTimeFormatter dateFileNameFormatter = new DateTimeFormatterBuilder()
|
||||||
.append(DateTimeFormatter.BASIC_ISO_DATE)
|
.appendValue(ChronoField.YEAR, 4)
|
||||||
|
.appendValue(ChronoField.MONTH_OF_YEAR, 2)
|
||||||
|
.appendValue(ChronoField.DAY_OF_MONTH, 2)
|
||||||
.appendLiteral('-')
|
.appendLiteral('-')
|
||||||
.appendValue(ChronoField.HOUR_OF_DAY, 2) // there is no DateTimeFormatter.BASIC_ISO_TIME
|
.appendValue(ChronoField.HOUR_OF_DAY, 2)
|
||||||
.appendValue(ChronoField.MINUTE_OF_HOUR, 2)
|
.appendValue(ChronoField.MINUTE_OF_HOUR, 2)
|
||||||
.appendValue(ChronoField.SECOND_OF_MINUTE, 2)
|
.appendValue(ChronoField.SECOND_OF_MINUTE, 2)
|
||||||
.toFormatter();
|
.toFormatter();
|
||||||
|
Loading…
Reference in New Issue
Block a user