Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions e2e/src/api/specs/library.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,47 @@ describe('/libraries', () => {
utils.removeImageFile(`${testAssetDir}/temp/reimport/asset.jpg`);
});

it('should not reimport a modified file more than once', async () => {
const library = await utils.createLibrary(admin.accessToken, {
ownerId: admin.userId,
importPaths: [`${testAssetDirInternal}/temp/reimport`],
});

utils.createImageFile(`${testAssetDir}/temp/reimport/asset.jpg`);
await utimes(`${testAssetDir}/temp/reimport/asset.jpg`, 447_775_200_000);

await utils.scan(admin.accessToken, library.id);

cpSync(`${testAssetDir}/albums/nature/tanners_ridge.jpg`, `${testAssetDir}/temp/reimport/asset.jpg`);
await utimes(`${testAssetDir}/temp/reimport/asset.jpg`, 447_775_200_001);

await utils.scan(admin.accessToken, library.id);

cpSync(`${testAssetDir}/albums/nature/el_torcal_rocks.jpg`, `${testAssetDir}/temp/reimport/asset.jpg`);
await utimes(`${testAssetDir}/temp/reimport/asset.jpg`, 447_775_200_001);

await utils.scan(admin.accessToken, library.id);

const { assets } = await utils.searchAssets(admin.accessToken, {
libraryId: library.id,
});

expect(assets.count).toEqual(1);

const asset = await utils.getAssetInfo(admin.accessToken, assets.items[0].id);

expect(asset).toEqual(
expect.objectContaining({
originalFileName: 'asset.jpg',
exifInfo: expect.objectContaining({
model: 'NIKON D750',
}),
}),
);

utils.removeImageFile(`${testAssetDir}/temp/reimport/asset.jpg`);
});

it('should set an asset offline if its file is missing', async () => {
const library = await utils.createLibrary(admin.accessToken, {
ownerId: admin.userId,
Expand Down
6 changes: 0 additions & 6 deletions server/src/services/metadata.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ describe(MetadataService.name, () => {
id: assetStub.image.id,
duration: null,
fileCreatedAt: sidecarDate,
fileModifiedAt: new Date('2023-02-23T05:06:29.716Z'),
localDateTime: sidecarDate,
});
});
Expand All @@ -247,7 +246,6 @@ describe(MetadataService.name, () => {
id: assetStub.image.id,
duration: null,
fileCreatedAt: fileModifiedAt,
fileModifiedAt,
localDateTime: fileModifiedAt,
});
});
Expand All @@ -265,7 +263,6 @@ describe(MetadataService.name, () => {
id: assetStub.image.id,
duration: null,
fileCreatedAt,
fileModifiedAt,
localDateTime: fileCreatedAt,
});
});
Expand Down Expand Up @@ -300,7 +297,6 @@ describe(MetadataService.name, () => {
id: assetStub.image.id,
duration: null,
fileCreatedAt: assetStub.image.fileCreatedAt,
fileModifiedAt: assetStub.image.fileModifiedAt,
localDateTime: assetStub.image.fileCreatedAt,
});
});
Expand All @@ -323,7 +319,6 @@ describe(MetadataService.name, () => {
id: assetStub.withLocation.id,
duration: null,
fileCreatedAt: assetStub.withLocation.createdAt,
fileModifiedAt: assetStub.withLocation.createdAt,
localDateTime: new Date('2023-02-22T05:06:29.716Z'),
});
});
Expand Down Expand Up @@ -845,7 +840,6 @@ describe(MetadataService.name, () => {
id: assetStub.image.id,
duration: null,
fileCreatedAt: dateForTest,
fileModifiedAt: dateForTest,
localDateTime: dateForTest,
});
});
Expand Down
2 changes: 1 addition & 1 deletion server/src/services/metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class MetadataService extends BaseService {
duration: exifTags.Duration?.toString() ?? null,
localDateTime,
fileCreatedAt: exifData.dateTimeOriginal ?? undefined,
fileModifiedAt: exifData.modifyDate ?? undefined,
fileModifiedAt: stats.mtime,
});

await this.assetRepository.upsertJobStatus({
Expand Down
Loading