feat: automatically detect media location changes (#20256)

This commit is contained in:
Jason Rasmussen
2025-07-25 15:25:36 -04:00
committed by GitHub
parent 0fdeac0417
commit c6b25ef111
8 changed files with 43 additions and 8 deletions

View File

@@ -437,6 +437,15 @@ export class DatabaseRepository {
}
async migrateFilePaths(sourceFolder: string, targetFolder: string): Promise<void> {
// remove trailing slashes
if (sourceFolder.endsWith('/')) {
sourceFolder = sourceFolder.slice(0, -1);
}
if (targetFolder.endsWith('/')) {
targetFolder = targetFolder.slice(0, -1);
}
// escaping regex special characters with a backslash
const sourceRegex = '^' + sourceFolder.replaceAll(/[-[\]{}()*+?.,\\^$|#\s]/g, String.raw`\$&`);
const source = sql.raw(`'${sourceRegex}'`);