Skip to content
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

feat(mobile): add deduplication hash to backup headers #16133

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jpros
Copy link
Contributor

@jpros jpros commented Feb 16, 2025

Description

This PR introduces a mechanism to prevent duplicated asset uploads to the server. It leverages the existing x-immich-checksum header to send the asset’s SHA-1 checksum for validation before the full upload takes place.

Additionally, this PR implements a single-file checksum bridge between iOS and Android for Flutter, ensuring consistency across platforms.

By preventing unnecessary uploads, especially of large files, this change optimizes bandwidth usage and improves overall efficiency.

Next Steps

Since images with different resolutions or compression settings generate distinct SHA-1 checksums, the next step will be to explore a more robust approach to image deduplication.

Fixes
#1553 - Move to client side hashing

How Has This Been Tested?

I ran the iOS and Android app, tested the backup with new images, tested uploading an image to the server through the web, and then added the same asset to the device. I tried to back up this new file, and it detected the duplicate.

Checklist:

  • I have performed a self-review of my own code
  • [N/A] I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • [N/A] I have confirmed that any new dependencies are strictly necessary.
  • [N/A] I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services)

Copy link
Member

@bo0tzz bo0tzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bo0tzz bo0tzz changed the title Added hash calculation to backup headers, preventing duplicates upload feat(mobile): Add deduplication hash to backup headers Feb 16, 2025
@bo0tzz bo0tzz changed the title feat(mobile): Add deduplication hash to backup headers feat(mobile): add deduplication hash to backup headers Feb 16, 2025
Joao Paulo Ros added 3 commits February 16, 2025 16:10
Backup service now, instead of loading all local assets, is getting the current asset from the DB using the local ID.
@alextran1502
Copy link
Contributor

Hello, and thank you for the PR. I ran some tests and noticed the feature isn't working as intended. Perhaps it is related to our Dart http client.

The duplicated assets are still getting uploaded to the server.

You can reproduce by connecting to a slower WIFI frequency (2.4GHz) and uploading a larger duplicated file, the expected behavior is that the request would be skipped, but I am still seeing the upload bar progressing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants