mirror of
https://github.com/immich-app/immich.git
synced 2025-12-28 09:14:59 +03:00
fix: automatic media location migration without internal assets (#20489)
This commit is contained in:
@@ -86,12 +86,7 @@ export class CliService extends BaseService {
|
||||
}
|
||||
|
||||
for (const asset of assets) {
|
||||
paths.push(
|
||||
asset.originalPath,
|
||||
asset.sidecarPath,
|
||||
asset.encodedVideoPath,
|
||||
...asset.files.map((file) => file.path),
|
||||
);
|
||||
paths.push(asset.path);
|
||||
}
|
||||
|
||||
return paths.filter(Boolean) as string[];
|
||||
|
||||
@@ -97,18 +97,18 @@ export class StorageService extends BaseService {
|
||||
const current = StorageCore.getMediaLocation();
|
||||
const samples = await this.assetRepository.getFileSamples();
|
||||
if (samples.length > 0) {
|
||||
const originalPath = samples[0].originalPath;
|
||||
const path = samples[0].path;
|
||||
const savedValue = await this.systemMetadataRepository.get(SystemMetadataKey.MediaLocation);
|
||||
let previous = savedValue?.location || '';
|
||||
|
||||
if (!previous) {
|
||||
previous = originalPath.startsWith('upload/') ? 'upload' : '/usr/src/app/upload';
|
||||
previous = path.startsWith('upload/') ? 'upload' : '/usr/src/app/upload';
|
||||
}
|
||||
|
||||
if (previous !== current) {
|
||||
this.logger.log(`Media location changed (from=${previous}, to=${current})`);
|
||||
|
||||
if (!originalPath.startsWith(previous)) {
|
||||
if (!path.startsWith(previous)) {
|
||||
throw new Error(
|
||||
'Detected an inconsistent media location. For more information, see https://immich.app/errors#inconsistent-media-location',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user