// Path: core/src/main/java/de/otto/jlineup/file/FileUtils.java
// public class FileUtils {
// 
// 
//     public static void clearDirectory(String path) throws IOException {
//         Path directory = Paths.get(path);
//         try(DirectoryStream<Path> paths = Files.newDirectoryStream(directory);) {
//             paths.forEach(file -> {
//                 try {
//                     if (Files.isDirectory(file)) {
//                         clearDirectory(file.toAbsolutePath().toString());
//                     }
// 
//                     Files.delete(file);
//                 } catch (IOException e) {
//                     throw new UncheckedIOException(e);
//                 }
//             });
//         }
//     }
// 
//     public static void deleteDirectory(Path path) throws IOException {
//         clearDirectory(path.toString());
//         Files.deleteIfExists(path);
//     }
// 
//     public static void deleteDirectory(String path) throws IOException {
//         deleteDirectory(Paths.get(path));
//     }
// 
// }


import de.otto.jlineup.file.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.time.Instant;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Stream;
import static java.lang.invoke.MethodHandles.lookup;

        if (screenShotFiles != null) {
            Stream.of(screenShotFiles)
                    .map(File::toPath)
                    .filter(filesOlderThan(pointInTime))
                    .forEach(this::deleteFile);
        }
    }

    private void deleteReportsOlderThan(Duration duration) throws IOException {

        Instant pointInTime = Instant.now().minus(duration);

        LOG.info("delete reports older than {}", pointInTime);

        Files.list(path)
                .filter(filesOlderThan(pointInTime))
                .forEach(deletePath());
    }

    private void deleteFile(Path path) {
            try {
                Files.delete(path);
            } catch (IOException e) {
                e.printStackTrace();
            }
    }
    private Consumer<Path> deletePath() {
        return file -> {
            try {
// Path: core/src/main/java/de/otto/jlineup/file/FileUtils.java
// public class FileUtils {
// 
// 
//     public static void clearDirectory(String path) throws IOException {
//         Path directory = Paths.get(path);
//         try(DirectoryStream<Path> paths = Files.newDirectoryStream(directory);) {
//             paths.forEach(file -> {
//                 try {
//                     if (Files.isDirectory(file)) {
//                         clearDirectory(file.toAbsolutePath().toString());
//                     }
// 
//                     Files.delete(file);
//                 } catch (IOException e) {
//                     throw new UncheckedIOException(e);
//                 }
//             });
//         }
//     }
// 
//     public static void deleteDirectory(Path path) throws IOException {
//         clearDirectory(path.toString());
//         Files.deleteIfExists(path);
//     }
// 
//     public static void deleteDirectory(String path) throws IOException {
//         deleteDirectory(Paths.get(path));
//     }
// 
// }


// Path: web/src/main/java/de/otto/jlineup/service/Housekeeper.java
import de.otto.jlineup.file.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.time.Instant;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Stream;
import static java.lang.invoke.MethodHandles.lookup;


        if (screenShotFiles != null) {
            Stream.of(screenShotFiles)
                    .map(File::toPath)
                    .filter(filesOlderThan(pointInTime))
                    .forEach(this::deleteFile);
        }
    }

    private void deleteReportsOlderThan(Duration duration) throws IOException {

        Instant pointInTime = Instant.now().minus(duration);

        LOG.info("delete reports older than {}", pointInTime);

        Files.list(path)
                .filter(filesOlderThan(pointInTime))
                .forEach(deletePath());
    }

    private void deleteFile(Path path) {
            try {
                Files.delete(path);
            } catch (IOException e) {
                e.printStackTrace();
            }
    }
    private Consumer<Path> deletePath() {
        return file -> {
            try {
                FileUtils.deleteDirectory(file);