()
| 509 | } |
| 510 | |
| 511 | private void clean() { |
| 512 | if (maxDays.intValue() <= 0 || Files.notExists(getDirectoryAsPath())) { |
| 513 | return; |
| 514 | } |
| 515 | DELETE_FILES_SERVICE.submit(() -> { |
| 516 | try (DirectoryStream<Path> files = streamFilesForDelete()) { |
| 517 | for (Path file : files) { |
| 518 | Files.delete(file); |
| 519 | } |
| 520 | } catch (IOException ioe) { |
| 521 | reportError("Unable to delete log files older than [" + maxDays + "] days", null, |
| 522 | ErrorManager.GENERIC_FAILURE); |
| 523 | } |
| 524 | }); |
| 525 | } |
| 526 | |
| 527 | private DirectoryStream<Path> streamFilesForDelete() throws IOException { |
| 528 | LocalDate maxDaysOffset = LocalDate.now().minusDays(maxDays.intValue()); |
no test coverage detected