private void initLegacyStore(final boolean createIfNotExists, final Path localDir) {
        // Legacy store may not exist, e.g. for a recent deployment, or it may be empty
        try (final Stream<Path> pathStream = Files.list(localDir).filter(Files::isRegularFile)) {
            final boolean foundDataFile = pathStream.anyMatch(LmdbEnv::isLmdbDataFile);
            if (foundDataFile) {
                legacyRefDataStore = getOrCreateLegacyStore();
                if (legacyRefDataStore.isEmpty()) {
                    // This likely means all data has been migrated so delete it
                    closeAndDeleteLegacyStore();
                } else {
                    LOGGER.info("Found a non-empty legacy reference data store in {}. Migration of reference data " +
                                "will be performed on a stream by stream basis on demand.",
                            localDir.toAbsolutePath());
                    migrationCheckRequired = true;
                }
            } else {
                if (createIfNotExists) {
                    LOGGER.warn("TESTING ONLY! No legacy store found in {}, creating an empty one", localDir);
                    legacyRefDataStore = getOrCreateLegacyStore();
                    // createIfNotExists is only really here for migration testing so require a mig check
                    migrationCheckRequired = true;
                } else {
                    LOGGER.info("No legacy reference data store found in {}. No migration required.", localDir);
                    legacyRefDataStore = null;
                    migrationCheckRequired = false;
                }
            }
        } catch (IOException e) {
            throw new RuntimeException(LogUtil.message(
                    "Error listing files in {}: {}", localDir, e.getMessage()), e);
        }
    }
@return The count of feed stores initialised, 1 or 0.
stroom-pipeline/src/main/java/stroom/pipeline/refdata/store/offheapstore/DelegatingRefDataOffHeapStore.java