Skip to content

Commit

Permalink
fix(server): do not reset fileCreatedDate
Browse files Browse the repository at this point in the history
When marking an offline asset as online again, do not reset the
fileCreatedAt value. This value contains the "true" date, copied
from exif.dateTimeOriginal. If we overwrite this value, we'd need
to run the metadata extraction job again. Instead, we just leave
the old (and correct) value in place.

fixes #15640
  • Loading branch information
C-Otto committed Jan 25, 2025
1 parent 947c053 commit 9444346
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions server/src/services/library.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,27 @@ describe(LibraryService.name, () => {
originalFileName: 'path.jpg',
});
});

// regression test for https://github.com/immich-app/immich/issues/15640
it('should not touch fileCreatedAt when un-trashing an asset previously marked as offline', async () => {
// After the initial import, fileCreatedAt is overwritten with metadata information (dateTimeOriginal).
// We need to retain this information. If we overwrite this, we'd need to trigger a new metadata extraction job.

const mockAssetJob: ILibraryAssetJob = {
id: assetStub.external.id,
importPaths: ['/'],
exclusionPatterns: [],
};

assetMock.getById.mockResolvedValue(assetStub.trashedOffline);
storageMock.stat.mockResolvedValue({ mtime: assetStub.trashedOffline.fileModifiedAt } as Stats);

await expect(sut.handleSyncAsset(mockAssetJob)).resolves.toBe(JobStatus.SUCCESS);

expect(assetMock.updateAll).toHaveBeenCalledWith([assetStub.trashedOffline.id], expect.not.objectContaining({
"fileCreatedAt": expect.anything(),
}));
});
});

it('should update file when mtime has changed', async () => {
Expand Down

0 comments on commit 9444346

Please sign in to comment.