mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix: avoid unnecessary writes to system metadata repository (#20538)
Co-authored-by: Zack Pollard <zackpollard@ymail.com>
This commit is contained in:
parent
af10c3bc2f
commit
01a9f735c8
1 changed files with 6 additions and 2 deletions
|
|
@ -96,9 +96,10 @@ export class StorageService extends BaseService {
|
||||||
await this.databaseRepository.withLock(DatabaseLock.MediaLocation, async () => {
|
await this.databaseRepository.withLock(DatabaseLock.MediaLocation, async () => {
|
||||||
const current = StorageCore.getMediaLocation();
|
const current = StorageCore.getMediaLocation();
|
||||||
const samples = await this.assetRepository.getFileSamples();
|
const samples = await this.assetRepository.getFileSamples();
|
||||||
|
const savedValue = await this.systemMetadataRepository.get(SystemMetadataKey.MediaLocation);
|
||||||
if (samples.length > 0) {
|
if (samples.length > 0) {
|
||||||
const path = samples[0].path;
|
const path = samples[0].path;
|
||||||
const savedValue = await this.systemMetadataRepository.get(SystemMetadataKey.MediaLocation);
|
|
||||||
let previous = savedValue?.location || '';
|
let previous = savedValue?.location || '';
|
||||||
|
|
||||||
if (!previous && this.configRepository.getEnv().storage.mediaLocation) {
|
if (!previous && this.configRepository.getEnv().storage.mediaLocation) {
|
||||||
|
|
@ -125,7 +126,10 @@ export class StorageService extends BaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only set MediaLocation in systemMetadataRepository if needed
|
||||||
|
if (savedValue?.location !== current) {
|
||||||
await this.systemMetadataRepository.set(SystemMetadataKey.MediaLocation, { location: current });
|
await this.systemMetadataRepository.set(SystemMetadataKey.MediaLocation, { location: current });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue