File tree Expand file tree Collapse file tree
src/main/java/fr/insee/genesis/domain/service/volumetry Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515import java .nio .file .StandardOpenOption ;
1616import java .time .LocalDateTime ;
1717import java .time .format .DateTimeFormatter ;
18+ import java .time .format .DateTimeParseException ;
1819import java .util .HashMap ;
1920import java .util .HashSet ;
2021import java .util .Map ;
@@ -122,12 +123,17 @@ public void cleanOldFiles() throws IOException {
122123 String datePart = logFilePath .getFileName ().toString ()
123124 .split (Constants .VOLUMETRY_FILE_SUFFIX + "\\ .csv" )[0 ] // Delete common suffix
124125 .replace ("_RAW" , "" ); // Delete "_RAW" if present
125- if (LocalDateTime .parse (datePart , DateTimeFormatter .ofPattern (Constants .VOLUMETRY_FILE_DATE_FORMAT ))
126- .isBefore (LocalDateTime .now ().minusDays (Constants .VOLUMETRY_FILE_EXPIRATION_DAYS ))
127- ) {
128- Files .deleteIfExists (logFilePath );
129- log .info ("Deleted {}" , logFilePath );
126+ try {
127+ if (LocalDateTime .parse (datePart , DateTimeFormatter .ofPattern (Constants .VOLUMETRY_FILE_DATE_FORMAT ))
128+ .isBefore (LocalDateTime .now ().minusDays (Constants .VOLUMETRY_FILE_EXPIRATION_DAYS ))
129+ ) {
130+ Files .deleteIfExists (logFilePath );
131+ log .info ("Deleted {}" , logFilePath );
132+ }
133+ }catch (DateTimeParseException dtpe ){
134+ log .warn (dtpe .toString ());
130135 }
136+
131137 }
132138 }
133139 }
You can’t perform that action at this time.
0 commit comments