public void scan() {
        final TaskContext taskContext = taskContextFactory.current();
        taskContext.info(() -> "Starting orphan file finder");
        LOGGER.info("{} - Starting, using logger name: '{}'", TASK_NAME, ORPHAN_FILE_LOGGER.getName());
        ORPHAN_FILE_LOGGER.info("Starting {} at {}", TASK_NAME, DateUtil.createNormalDateTimeString());
        ORPHAN_FILE_LOGGER.info("Orphaned files/directories:");
        final DurationTimer durationTimer = DurationTimer.start();

        final AtomicLong counter = new AtomicLong();
        final FsOrphanFileFinderSummary summary = new FsOrphanFileFinderSummary();
        final Consumer<Path> orphanConsumer = path -> {
            LOGGER.debug(() -> "Unexpected file in store: " +
                    FileUtil.getCanonicalPath(path));

            ORPHAN_FILE_LOGGER.info(FileUtil.getCanonicalPath(path));

            summary.addPath(path);
            counter.incrementAndGet();
        };

        try {
            scan(orphanConsumer, taskContext);

            if (Thread.currentThread().isInterrupted() || taskContext.isTerminated()) {
                final String state = Thread.currentThread().isInterrupted()
                        ? "interrupted"
                        : "terminated";
                ORPHAN_FILE_LOGGER.info("--- {} task {} at {} ---",
                        TASK_NAME,
                        state,
                        DateUtil.createNormalDateTimeString());
                LOGGER.info(LogUtil.message("{} - {} in {}",
                        TASK_NAME, state, durationTimer));
            } else {
                ORPHAN_FILE_LOGGER.info(summary.toString());
                ORPHAN_FILE_LOGGER.info("Completed {} at {} in {}, found {} orphaned files/directories",
                        TASK_NAME,
                        DateUtil.createNormalDateTimeString(),
                        durationTimer,
                        counter.get());
                LOGGER.info(LogUtil.message("{} - Finished, in {}.", TASK_NAME, durationTimer));
            }
        } catch (Exception e) {
            ORPHAN_FILE_LOGGER.info("--- {} task failed at {} due to: {} ---",
                    TASK_NAME,
                    DateUtil.createNormalDateTimeString(),
                    e.getMessage());
            throw e;
        }
    }
Task to clean the stream store.
stroom-data/stroom-data-store-impl-fs/src/main/java/stroom/data/store/impl/fs/FsOrphanFileFinderExecutor.java