mirror of
https://github.com/immich-app/immich.git
synced 2025-01-07 00:50:23 -05:00
fix(server): delete thumbnail for readonly asset (#8593)
* delete thumbnail and other generated files even for readonly asset * updated test * don't delete sidecar file for readonly file * fixed test * improved external detection
This commit is contained in:
parent
fff12e3d78
commit
7a16233584
2 changed files with 19 additions and 9 deletions
|
@ -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)
|
when(assetMock.getById)
|
||||||
.calledWith(assetStub.readOnly.id, {
|
.calledWith(assetStub.readOnly.id, {
|
||||||
faces: {
|
faces: {
|
||||||
|
@ -709,7 +709,20 @@ describe(AssetService.name, () => {
|
||||||
|
|
||||||
await sut.handleAssetDeletion({ id: assetStub.readOnly.id });
|
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);
|
expect(assetMock.remove).toHaveBeenCalledWith(assetStub.readOnly);
|
||||||
});
|
});
|
||||||
|
@ -748,7 +761,6 @@ describe(AssetService.name, () => {
|
||||||
assetStub.external.thumbnailPath,
|
assetStub.external.thumbnailPath,
|
||||||
assetStub.external.previewPath,
|
assetStub.external.previewPath,
|
||||||
assetStub.external.encodedVideoPath,
|
assetStub.external.encodedVideoPath,
|
||||||
assetStub.external.sidecarPath,
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -399,14 +399,12 @@ export class AssetService {
|
||||||
await this.jobRepository.queue({ name: JobName.ASSET_DELETION, data: { id: asset.livePhotoVideoId } });
|
await this.jobRepository.queue({ name: JobName.ASSET_DELETION, data: { id: asset.livePhotoVideoId } });
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = [asset.thumbnailPath, asset.previewPath, asset.encodedVideoPath, asset.sidecarPath];
|
const files = [asset.thumbnailPath, asset.previewPath, asset.encodedVideoPath];
|
||||||
if (!fromExternal) {
|
if (!(asset.isExternal || asset.isReadOnly)) {
|
||||||
files.push(asset.originalPath);
|
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;
|
return JobStatus.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue