-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(mobile): device asset entity to use modified time #17064
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2ceda80
to
3476f7d
Compare
alextran1502
reviewed
Apr 2, 2025
f4ac652
to
8f9cf97
Compare
alextran1502
reviewed
Apr 2, 2025
8f9cf97
to
e2d5b91
Compare
alextran1502
approved these changes
Apr 3, 2025
kirill-dev-pro
pushed a commit
to kirill-dev-pro/immich-but-with-public-albums-within-instance
that referenced
this pull request
Apr 6, 2025
…p#17064) * refactor: device asset entity to use modified time * chore: cleanup * refactor: remove album media dependency from hashservice * refactor: return updated copy of asset * add hash service tests * chore: rename hash batch constants * chore: log the number of assets processed during migration * chore: more logs * refactor: use lookup and more tests * use sort approach * refactor hash service to use for loop instead * refactor: rename to getByIds --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4939
Fixes #6439 (haven't tested the iOS part of the issue, the issue in Android does gets fixed)
Description
The current hashing implementation of the app is follows:
AndroidDeviceAssetSchema
orIOSDeviceAssetSchema
This approach has issues, especially when the asset is modified in-place outside immich after hashed by the app. When the asset is modified in-place and the platform does not make changes to the
localID
of the edited asset, our current approach proceeds to reuse the hash, even when the hash of the actual file is modified. The PR fixes this by also storing the asset'smodifiedTime
to the entity and compare it during lookup to reuse the hash.The existing approach also relied on updating object references inside collections to pass the updated hash back to the caller. This makes it hard to reason about the code. This has been refactored to make the logic simpler and understandable.
Even when the
localId
fromAssetEntity
were Strings, we were using two different device asset schemas to store the hashes. One for android which converted the string IDs to int and the iOS that stored the string IDs directly. The PR refactors this to use a common entity namedDeviceAssetEntitySchema
. Migration handling is also added to move the hashes from the existing schemas to the new schemas.