mirror of
https://github.com/immich-app/immich.git
synced 2025-03-11 02:23:09 -05:00
fix(server): don't reimport files more than once (#16375)
* fix(server) don't reimport files more than once * fix: test --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
a708649504
commit
d20e2e268a
3 changed files with 42 additions and 7 deletions
|
@ -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,
|
||||
|
|
|
@ -249,7 +249,6 @@ describe(MetadataService.name, () => {
|
|||
id: assetStub.image.id,
|
||||
duration: null,
|
||||
fileCreatedAt: sidecarDate,
|
||||
fileModifiedAt: new Date('2023-02-23T05:06:29.716Z'),
|
||||
localDateTime: sidecarDate,
|
||||
});
|
||||
});
|
||||
|
@ -269,7 +268,6 @@ describe(MetadataService.name, () => {
|
|||
id: assetStub.image.id,
|
||||
duration: null,
|
||||
fileCreatedAt: fileModifiedAt,
|
||||
fileModifiedAt,
|
||||
localDateTime: fileModifiedAt,
|
||||
});
|
||||
});
|
||||
|
@ -287,7 +285,6 @@ describe(MetadataService.name, () => {
|
|||
id: assetStub.image.id,
|
||||
duration: null,
|
||||
fileCreatedAt,
|
||||
fileModifiedAt,
|
||||
localDateTime: fileCreatedAt,
|
||||
});
|
||||
});
|
||||
|
@ -322,7 +319,6 @@ describe(MetadataService.name, () => {
|
|||
id: assetStub.image.id,
|
||||
duration: null,
|
||||
fileCreatedAt: assetStub.image.fileCreatedAt,
|
||||
fileModifiedAt: assetStub.image.fileModifiedAt,
|
||||
localDateTime: assetStub.image.fileCreatedAt,
|
||||
});
|
||||
});
|
||||
|
@ -345,7 +341,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'),
|
||||
});
|
||||
});
|
||||
|
@ -867,7 +862,6 @@ describe(MetadataService.name, () => {
|
|||
id: assetStub.image.id,
|
||||
duration: null,
|
||||
fileCreatedAt: dateForTest,
|
||||
fileModifiedAt: dateForTest,
|
||||
localDateTime: dateForTest,
|
||||
});
|
||||
});
|
||||
|
|
|
@ -248,7 +248,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({
|
||||
|
|
Loading…
Add table
Reference in a new issue