()
| 525 | } |
| 526 | |
| 527 | private DirectoryStream<Path> streamFilesForDelete() throws IOException { |
| 528 | LocalDate maxDaysOffset = LocalDate.now().minusDays(maxDays.intValue()); |
| 529 | return Files.newDirectoryStream(getDirectoryAsPath(), path -> { |
| 530 | boolean result = false; |
| 531 | String date = obtainDateFromPath(path); |
| 532 | if (date != null) { |
| 533 | try { |
| 534 | LocalDate dateFromFile = LocalDate.from(DateTimeFormatter.ISO_LOCAL_DATE.parse(date)); |
| 535 | result = dateFromFile.isBefore(maxDaysOffset); |
| 536 | } catch (DateTimeException ignore) { |
| 537 | // Unable to determine date from path. File will not be included. |
| 538 | } |
| 539 | } |
| 540 | return result; |
| 541 | }); |
| 542 | } |
| 543 | |
| 544 | private Path getDirectoryAsPath() { |
| 545 | return Path.of(directory); |
no test coverage detected