mirror of
https://github.com/immich-app/immich.git
synced 2026-03-01 18:19:10 +03:00
feat: automatically detect media location changes (#20256)
This commit is contained in:
@@ -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}'`);
|
||||
|
||||
Reference in New Issue
Block a user