fix(server): dont queue unneeded jobs when no xmp file exists (#31936)
fix(server): dont queue unneeded jobs when no xmp file exists (#31927) (cherry picked from commit 32e3239ba32f3f89b1b0b996c103333927b3324a) Co-authored-by: Jonathan Jogenfors <jonathan@jogenfors.se>
This commit is contained in:
co-authored by
Jonathan Jogenfors
parent
53d1584dd2
commit
7c102be619
@@ -20,6 +20,18 @@ describe(JobService.name, () => {
|
||||
});
|
||||
|
||||
describe('onJobRun', () => {
|
||||
it('should queue metadata extraction when sidecar discovery is skipped', async () => {
|
||||
const job: JobItem = { name: JobName.SidecarCheck, data: { id: 'asset-1', source: 'upload' } };
|
||||
mocks.job.run.mockResolvedValue(JobStatus.Skipped);
|
||||
|
||||
await sut.onJobRun(QueueName.Sidecar, job);
|
||||
|
||||
expect(mocks.job.queue).toHaveBeenCalledExactlyOnceWith({
|
||||
name: JobName.AssetExtractMetadata,
|
||||
data: job.data,
|
||||
});
|
||||
});
|
||||
|
||||
it('should process a successful job', async () => {
|
||||
mocks.job.run.mockResolvedValue(JobStatus.Success);
|
||||
|
||||
|
||||
@@ -1907,6 +1907,18 @@ describe(MetadataService.name, () => {
|
||||
expect(mocks.asset.update).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should skip database writes if no sidecar exists or was previously recorded', async () => {
|
||||
const asset = forSidecarJob();
|
||||
|
||||
mocks.assetJob.getForSidecarCheckJob.mockResolvedValue(asset);
|
||||
mocks.storage.checkFileExists.mockResolvedValue(false);
|
||||
|
||||
await expect(sut.handleSidecarCheck({ id: asset.id })).resolves.toBe(JobStatus.Skipped);
|
||||
|
||||
expect(mocks.asset.upsertFile).not.toHaveBeenCalled();
|
||||
expect(mocks.asset.deleteFile).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should detect a new sidecar at .jpg.xmp', async () => {
|
||||
const asset = forSidecarJob({ originalPath: '/path/to/IMG_123.jpg', files: [] });
|
||||
|
||||
|
||||
@@ -448,7 +448,7 @@ export class MetadataService extends BaseService {
|
||||
|
||||
const { sidecarFile } = getAssetFiles(asset.files);
|
||||
|
||||
const isChanged = sidecarPath !== sidecarFile?.path;
|
||||
const isChanged = sidecarPath !== (sidecarFile?.path ?? null);
|
||||
|
||||
if (sidecarFile?.path || sidecarPath) {
|
||||
this.logger.debug(
|
||||
|
||||
Reference in New Issue
Block a user