Skip to content

feature(mobile): Hardening synchronization mechanism + Pull to refresh - #2085

Merged
alextran1502 merged 3 commits into
mainfrom
dev/mobile-sync-fixes
Mar 27, 2023
Merged

alextran1502 merged 3 commits into
mainfrom
dev/mobile-sync-fixes

Conversation

@fyfrey

@fyfrey fyfrey commented Mar 25, 2023 •

Copy link
Copy Markdown
Collaborator

This PR tries to fix several issues with the new client database sync:

and adds pull to refresh on the main timeline:

You can refresh assets on the main timeline with the usual material design refresh gesture by pulling down. If you that twice (within 2 seconds after the first refresh finished), a full clean and reload is performed, i.e. all assets and albums are purged from the DB and re-synced from device and server.

Changes:

  • Removes the unique constraint on localId & deviceId: allows duplicates from web/cli or uploaded from the same mobile device with different users
  • syncing remote to local assets is updated to allow for duplicates: sort and compare by userId, deviceId, localId and modification time (to account for duplicates originating from edited files imported via CLI)
  • keeps backed-up assets as remote in teh database after deleting the local files on the device
  • Add AssetType to Asset
  • Adds a version setting to the database
  • Migrate client database: clears the assets in the client database once
  • No longer uses UTC when creating Asset (as Isar always returns dates in local time)
  • implements == and hashCode for Asset so that changes to the list of assets actually result in a re-render of the timeline
  • adjust log level of database errors
  • changes logging to async write (because you cannot run sync and async write operations in the same isolate at the same time)
  • adds some tests for the SyncService
  • serialize sync operations to guard against concurrency bugs
  • reworked onNewAssetUploaded

@vercel

vercel Bot commented Mar 25, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
immich ⬜️ Ignored (Inspect) Mar 26, 2023 at 4:53PM (UTC)

@fyfrey
fyfrey requested a review from alextran1502 March 25, 2023 18:13
@alextran1502

alextran1502 commented Mar 26, 2023 •

Copy link
Copy Markdown
Member

This looks good Fynn! Thank you very much. I can confirm that it fixed the error of the unique index.

I am still observing the mismatching of the icon and some rendering issue on the main timeline when the uploading process is in progress

Step to reproduce is as follows.

  1. Start backing up
  2. Return to the main timeline
  3. You will see the timeline update with newly uploaded assets. However, in some instances, the local asset isn't replaced by the remote asset; instead, the remote asset is added to the timeline, showing duplication.
  4. Navigate to the upload screen
  5. Navigate to the main timeline screen. Now the duplicated assets are resolved/consolidated into one and no longer show duplication. However, some of the icons only show the cloud icon instead of the cloud with the checkmark.

The workaround is to sign out and sign back in, it would then show the correct icon

Let me know if you can reproduce the issue.

@fyfrey fyfrey changed the title fix(mobile): allow syncing duplicate local IDs feature(mobile): allow syncing duplicate local IDs & pull to refresh Mar 26, 2023
@fyfrey
fyfrey force-pushed the dev/mobile-sync-fixes branch from f6fdd36 to d332c78 Compare March 26, 2023 16:53
@fyfrey

fyfrey commented Mar 26, 2023

Copy link
Copy Markdown
Collaborator Author

This looks good Fynn! Thank you very much. I can confirm that it fixed the error of the unique index.

Very good!

I am still observing the mismatching of the icon and some rendering issue on the main timeline when the uploading process is in progress
[...]
Let me know if you can reproduce the issue.

I was able to reproduce the issue. The reason is twofold: onNewAssetUploaded was not updated to account for the different ordered asset list. Further, it would run concurrently with the full sync operations leading to buggy DB states depending on which function started processing earlier. I've fixed this by putting more previously external functions under the async mutex in SyncService.

As a bonus, I've implemented pull to refresh on main timeline (see the updated PR description)

@alextran1502 alextran1502 changed the title feature(mobile): allow syncing duplicate local IDs & pull to refresh feature(mobile): Hardening synchronization mechanism + Pull to refresh Mar 27, 2023
@alextran1502
alextran1502 merged commit cae3765 into main Mar 27, 2023
@alextran1502
alextran1502 deleted the dev/mobile-sync-fixes branch March 27, 2023 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants