1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-10 23:22:22 +02:00

fix(server): don't delete offline files from disk when trash empties (#14777)

fix: don't delete offline files from disk when emptying trash

Move logic to asset deletion check
This commit is contained in:
Jonathan Jogenfors
2025-01-07 19:25:43 +01:00
committed by GitHub
parent 10e569cc1c
commit 23f3e737fd
6 changed files with 289 additions and 23 deletions

View File

@@ -188,7 +188,7 @@ export class AssetService extends BaseService {
name: JobName.ASSET_DELETION,
data: {
id: asset.id,
deleteOnDisk: true,
deleteOnDisk: !asset.isOffline,
},
})),
);
@@ -249,6 +249,7 @@ export class AssetService extends BaseService {
const { thumbnailFile, previewFile } = getAssetFiles(asset.files);
const files = [thumbnailFile?.path, previewFile?.path, asset.encodedVideoPath];
if (deleteOnDisk) {
files.push(asset.sidecarPath, asset.originalPath);
}

View File

@@ -18,7 +18,7 @@ export class TrashService extends BaseService {
await this.trashRepository.restoreAll(ids);
await this.eventRepository.emit('assets.restore', { assetIds: ids, userId: auth.user.id });
this.logger.log(`Restored ${ids.length} assets from trash`);
this.logger.log(`Restored ${ids.length} asset(s) from trash`);
return { count: ids.length };
}
@@ -26,7 +26,7 @@ export class TrashService extends BaseService {
async restore(auth: AuthDto): Promise<TrashResponseDto> {
const count = await this.trashRepository.restore(auth.user.id);
if (count > 0) {
this.logger.log(`Restored ${count} assets from trash`);
this.logger.log(`Restored ${count} asset(s) from trash`);
}
return { count };
}
@@ -52,7 +52,7 @@ export class TrashService extends BaseService {
);
for await (const assetIds of assetPagination) {
this.logger.debug(`Queueing ${assetIds.length} assets for deletion from the trash`);
this.logger.debug(`Queueing ${assetIds.length} asset(s) for deletion from the trash`);
count += assetIds.length;
await this.jobRepository.queueAll(
assetIds.map((assetId) => ({
@@ -65,7 +65,7 @@ export class TrashService extends BaseService {
);
}
this.logger.log(`Queued ${count} assets for deletion from the trash`);
this.logger.log(`Queued ${count} asset(s) for deletion from the trash`);
return JobStatus.SUCCESS;
}