···1313import { projectDir } from './index.js';
1414import path from 'path';
1515import { cacheFunctions } from "@foxxmd/regex-buddy-core";
1616-import { fileOrDirectoryIsWriteable } from '../utils/FSUtils.js';
1616+import { fileExists, fileOrDirectoryIsWriteable } from '../utils/FSUtils.js';
1717+import { copyFile } from 'fs/promises';
1718import { asCacheAuthProvider, asCacheConfig, asCacheMetadataProvider, asCacheScrobbleProvider, CacheAuthProvider, CacheConfig, CacheConfigOptions, CacheMetadataProvider, CacheProvider, CacheScrobbleProvider } from './infrastructure/Atomic.js';
1819import { Typeson } from 'typeson';
1920import { builtin } from 'typeson-registry';
···382383 fileOrDirectoryIsWriteable(cachePath);
383384 } catch (e) {
384385 throw new Error(`Unable to use path for file cache at ${cachePath}`, { cause: e })
386386+ }
387387+388388+ if(fileExists(cachePath) && !fileExists(`${cachePath}.bak`)) {
389389+ logger.info(`Backing up ${cachePath} in preparation for migration to database...`);
390390+ await copyFile(cachePath, `${cachePath}.bak`);
391391+ logger.info(`Done! Backed up to ${cachePath}.bak\nAll data has been loaded into cache. It will be deleted (from cache) after migrating to database.\nIf there are migration issues or you wish to downgrade then overwrite ${cachePath} with the .bak backup copy`);
385392 }
386393387394 const streamPromise = new Promise((resolve, reject) => {