mirror of
https://github.com/Art051/immich.git
synced 2025-08-11 19:29:00 +00:00
* save thumbnails in subdirectories * migration job, migrate assets and face thumbnails * fix tests * directory depth of two instead of three * cleanup empty dirs after migration * clean up empty dirs after migration, migrate people without assetId * add job card for new migration job * fix removeEmptyDirs race condition because of missing await * cleanup empty directories after asset deletion * move ensurePath to storage core * rename jobs * remove unnecessary property of IEntityJob * use updated person getById, minor refactoring * ensure that directory cleanup doesn't interfere with migration * better description for job in ui * fix remove directories when migration is done * cleanup empty folders at start of migration * fix: actually persist concurrency setting * add comment explaining regex * chore: cleanup --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { Inject, Injectable, Logger } from '@nestjs/common';
|
|
import { IDeleteFilesJob } from '../job';
|
|
import { StorageCore, StorageFolder } from './storage.core';
|
|
import { IStorageRepository } from './storage.repository';
|
|
|
|
@Injectable()
|
|
export class StorageService {
|
|
private logger = new Logger(StorageService.name);
|
|
private storageCore: StorageCore;
|
|
|
|
constructor(@Inject(IStorageRepository) private storageRepository: IStorageRepository) {
|
|
this.storageCore = new StorageCore(storageRepository);
|
|
}
|
|
|
|
init() {
|
|
const libraryBase = this.storageCore.getBaseFolder(StorageFolder.LIBRARY);
|
|
this.storageRepository.mkdirSync(libraryBase);
|
|
}
|
|
|
|
async handleDeleteFiles(job: IDeleteFilesJob) {
|
|
const { files } = job;
|
|
|
|
// TODO: one job per file
|
|
for (const file of files) {
|
|
if (!file) {
|
|
continue;
|
|
}
|
|
|
|
try {
|
|
await this.storageRepository.unlink(file);
|
|
} catch (error: any) {
|
|
this.logger.warn('Unable to remove file from disk', error);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|