@Override
                            public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) {
                                // The parent dir has files so we won't be considering the dir for deletion.
                                dirAges.remove(file.getParent());

                                taskContext.info(() -> FileUtil.getCanonicalPath(file));
                                cleanProgress.addFile();

                                if (Thread.currentThread().isInterrupted() || taskContext.isTerminated()) {
                                    return FileVisitResult.TERMINATE;
                                }

                                // Process only raw zip repo files, i.e. files that have not already been created
                                // by the fragmenting process.
                                final long id = fileSystemStreamPathHelper.getId(file);
                                LOGGER.trace(() -> "Got id = " + id + " for file " + FileUtil.getCanonicalPath(file));

                                if (id == -1) {
                                    LOGGER.trace(() -> "Orphan file as no id: " + FileUtil.getCanonicalPath(file));
                                    cleanProgress.addOrphanCount();
                                    orphanConsumer.accept(file);
                                } else {
                                    fileMap.computeIfAbsent(id, k -> new HashSet<>()).add(file);
                                }

                                if (fileMap.size() >= BATCH_SIZE) {
                                    // Validate the batch of files against the DB.
                                    validateFiles(fileMap, cleanProgress, orphanConsumer, taskContext);
                                    fileMap.clear();
                                }

                                return FileVisitResult.CONTINUE;
                            }
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