mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 04:05:39 -04: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
@ -526,6 +526,47 @@ describe('/libraries', () => {
|
|||||||
utils.removeImageFile(`${testAssetDir}/temp/reimport/asset.jpg`);
|
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 () => {
|
it('should set an asset offline if its file is missing', async () => {
|
||||||
const library = await utils.createLibrary(admin.accessToken, {
|
const library = await utils.createLibrary(admin.accessToken, {
|
||||||
ownerId: admin.userId,
|
ownerId: admin.userId,
|
||||||
|
@ -249,7 +249,6 @@ describe(MetadataService.name, () => {
|
|||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
duration: null,
|
duration: null,
|
||||||
fileCreatedAt: sidecarDate,
|
fileCreatedAt: sidecarDate,
|
||||||
fileModifiedAt: new Date('2023-02-23T05:06:29.716Z'),
|
|
||||||
localDateTime: sidecarDate,
|
localDateTime: sidecarDate,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -269,7 +268,6 @@ describe(MetadataService.name, () => {
|
|||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
duration: null,
|
duration: null,
|
||||||
fileCreatedAt: fileModifiedAt,
|
fileCreatedAt: fileModifiedAt,
|
||||||
fileModifiedAt,
|
|
||||||
localDateTime: fileModifiedAt,
|
localDateTime: fileModifiedAt,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -287,7 +285,6 @@ describe(MetadataService.name, () => {
|
|||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
duration: null,
|
duration: null,
|
||||||
fileCreatedAt,
|
fileCreatedAt,
|
||||||
fileModifiedAt,
|
|
||||||
localDateTime: fileCreatedAt,
|
localDateTime: fileCreatedAt,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -322,7 +319,6 @@ describe(MetadataService.name, () => {
|
|||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
duration: null,
|
duration: null,
|
||||||
fileCreatedAt: assetStub.image.fileCreatedAt,
|
fileCreatedAt: assetStub.image.fileCreatedAt,
|
||||||
fileModifiedAt: assetStub.image.fileModifiedAt,
|
|
||||||
localDateTime: assetStub.image.fileCreatedAt,
|
localDateTime: assetStub.image.fileCreatedAt,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -345,7 +341,6 @@ describe(MetadataService.name, () => {
|
|||||||
id: assetStub.withLocation.id,
|
id: assetStub.withLocation.id,
|
||||||
duration: null,
|
duration: null,
|
||||||
fileCreatedAt: assetStub.withLocation.createdAt,
|
fileCreatedAt: assetStub.withLocation.createdAt,
|
||||||
fileModifiedAt: assetStub.withLocation.createdAt,
|
|
||||||
localDateTime: new Date('2023-02-22T05:06:29.716Z'),
|
localDateTime: new Date('2023-02-22T05:06:29.716Z'),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -867,7 +862,6 @@ describe(MetadataService.name, () => {
|
|||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
duration: null,
|
duration: null,
|
||||||
fileCreatedAt: dateForTest,
|
fileCreatedAt: dateForTest,
|
||||||
fileModifiedAt: dateForTest,
|
|
||||||
localDateTime: dateForTest,
|
localDateTime: dateForTest,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -248,7 +248,7 @@ export class MetadataService extends BaseService {
|
|||||||
duration: exifTags.Duration?.toString() ?? null,
|
duration: exifTags.Duration?.toString() ?? null,
|
||||||
localDateTime,
|
localDateTime,
|
||||||
fileCreatedAt: exifData.dateTimeOriginal ?? undefined,
|
fileCreatedAt: exifData.dateTimeOriginal ?? undefined,
|
||||||
fileModifiedAt: exifData.modifyDate ?? undefined,
|
fileModifiedAt: stats.mtime,
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.assetRepository.upsertJobStatus({
|
await this.assetRepository.upsertJobStatus({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user