feat!: absolute file paths (#19995)

feat: absolute file paths
This commit is contained in:
Jason Rasmussen
2025-07-18 10:57:29 -04:00
committed by GitHub
parent f32d4f15b6
commit 493d85b021
34 changed files with 689 additions and 257 deletions
+15 -4
View File
@@ -1,5 +1,6 @@
import { Injectable } from '@nestjs/common';
import { join, resolve } from 'node:path';
import { join } from 'node:path';
import { APP_MEDIA_LOCATION } from 'src/constants';
import { StorageCore } from 'src/cores/storage.core';
import { OnEvent, OnJob } from 'src/decorators';
import { DatabaseLock, JobName, JobStatus, QueueName, StorageFolder, SystemMetadataKey } from 'src/enum';
@@ -60,6 +61,17 @@ export class StorageService extends BaseService {
}
}
});
await this.databaseRepository.withLock(DatabaseLock.MediaLocation, async () => {
const current = APP_MEDIA_LOCATION;
const savedValue = await this.systemMetadataRepository.get(SystemMetadataKey.MediaLocation);
const previous = savedValue?.location || '';
if (previous !== current) {
this.logger.log(`Media location changed (from=${previous}, to=${current})`);
await this.systemMetadataRepository.set(SystemMetadataKey.MediaLocation, { location: current });
}
});
}
@OnJob({ name: JobName.FileDelete, queue: QueueName.BackgroundTask })
@@ -87,9 +99,8 @@ export class StorageService extends BaseService {
try {
await this.storageRepository.readFile(internalPath);
} catch (error) {
const fullyQualifiedPath = resolve(process.cwd(), internalPath);
this.logger.error(`Failed to read ${fullyQualifiedPath} (${internalPath}): ${error}`);
throw new ImmichStartupError(`Failed to read: "${externalPath} (${fullyQualifiedPath}) - ${docsMessage}"`);
this.logger.error(`Failed to read (${internalPath}): ${error}`);
throw new ImmichStartupError(`Failed to read: "${externalPath} (${internalPath}) - ${docsMessage}"`);
}
}