private void validateFiles(final Map<Long, Set<Path>> fileMap,
                               final FsOrphanFileFinderProgress cleanProgress,
                               final Consumer<Path> orphanConsumer,
                               final TaskContext taskContext) {
        // See if all the meta ids from the files exist in the db
        final Set<Long> metaIdSet = metaService.exists(fileMap.keySet());

//        // If we have had the same number of results from the DB that we asked for then all is good.
//        final Se<Meta> metaList = resultPage.getValues();
        if (metaIdSet.size() != fileMap.size()) {
            LOGGER.debug(() -> LogUtil.message(
                    "metaIdSet is is different size to file map: " +
                            "metaIdSet.size(): {}, fileMap.size(): {}, batch size {}",
                    metaIdSet.size(), fileMap.size(), BATCH_SIZE));

            // Determine which files are orphans.
            metaIdSet.forEach(fileMap::remove);

            fileMap.values()
                    .forEach(list -> list
                            .stream()
                            .takeWhile(item ->
                                    !Thread.currentThread().isInterrupted() && !taskContext.isTerminated())
                            .forEach(file -> {
                                LOGGER.trace(() -> "Orphan file: " + FileUtil.getCanonicalPath(file));
                                if (Files.isRegularFile(file)) {
                                    cleanProgress.addOrphanCount();
                                    orphanConsumer.accept(file);
                                }
                            }));
        }
    }
API used by the tasks to interface to the stream store under the bonnet.
stroom-data/stroom-data-store-impl-fs/src/main/java/stroom/data/store/impl/fs/FsOrphanFileFinder.java