Skip to content

High performance self-hosted photo and video management solution.

fix(server): delete thumbnail for readonly asset (#8593)

Kevin Huang7a16233584e3
diff --git a/server/src/services/asset.service.spec.ts b/server/src/services/asset.service.spec.ts
index b90c194aa0..28841836f2 100755
--- a/server/src/services/asset.service.spec.ts
+++ b/server/src/services/asset.service.spec.ts
@@ -695,7 +695,7 @@ describe(AssetService.name, () => {
});
});
- it('should not schedule delete-files job for readonly assets', async () => {
+ it('should only delete generated files for readonly assets', async () => {
when(assetMock.getById)
.calledWith(assetStub.readOnly.id, {
faces: {
@@ -709,7 +709,20 @@ describe(AssetService.name, () => {
await sut.handleAssetDeletion({ id: assetStub.readOnly.id });
- expect(jobMock.queue.mock.calls).toEqual([]);
+ expect(jobMock.queue.mock.calls).toEqual([
+ [
+ {
+ name: JobName.DELETE_FILES,
+ data: {
+ files: [
+ assetStub.readOnly.thumbnailPath,
+ assetStub.readOnly.previewPath,
+ assetStub.readOnly.encodedVideoPath,
+ ],
+ },
+ },
+ ],
+ ]);
expect(assetMock.remove).toHaveBeenCalledWith(assetStub.readOnly);
});
@@ -748,7 +761,6 @@ describe(AssetService.name, () => {
assetStub.external.thumbnailPath,
assetStub.external.previewPath,
assetStub.external.encodedVideoPath,
- assetStub.external.sidecarPath,
],
},
},
diff --git a/server/src/services/asset.service.ts b/server/src/services/asset.service.ts
index 135377e0bd..606a5f62e2 100644
--- a/server/src/services/asset.service.ts
+++ b/server/src/services/asset.service.ts
@@ -399,14 +399,12 @@ export class AssetService {
await this.jobRepository.queue({ name: JobName.ASSET_DELETION, data: { id: asset.livePhotoVideoId } });
}
- const files = [asset.thumbnailPath, asset.previewPath, asset.encodedVideoPath, asset.sidecarPath];
- if (!fromExternal) {
- files.push(asset.originalPath);
+ const files = [asset.thumbnailPath, asset.previewPath, asset.encodedVideoPath];
+ if (!(asset.isExternal || asset.isReadOnly)) {
+ files.push(asset.sidecarPath, asset.originalPath);
}
- if (!asset.isReadOnly) {
- await this.jobRepository.queue({ name: JobName.DELETE_FILES, data: { files } });
- }
+ await this.jobRepository.queue({ name: JobName.DELETE_FILES, data: { files } });
return JobStatus.SUCCESS;
}