Skip to content

Conversation

@shenlong-tanwen
Copy link
Member

Description

Removes stale assets from the SQLite DB that are not accessible by the current user. The delete events for said assets are not sent from the server during the sync process and the client is expected to clean them up.

@alextran1502
Copy link
Member

Could you explain in more detail how this scenario can occur?

@shenlong-tanwen shenlong-tanwen marked this pull request as ready for review October 2, 2025 13:07
@shenlong-tanwen
Copy link
Member Author

Could you explain in more detail how this scenario can occur?

So we have sync events to add assets that come from shared albums, but the server does not send anything when a shared album is removed. The same goes for partner assets, we have partner asset deletes that removes an asset when it is removed by the partner, but we do not remove the partners assets when they are no longer a partner of the current user. It is up to the client to handle cleaning them.

The way I tested this PR is by:

  • Creating a new user
  • Share an existing album to this user
  • Login and let the mobile app sync the assets for this new user (Which should only be the assets from the shared album)
  • Verify the current remote asset count in Sync status page
  • Once they are synced, remove the new user from the album share
  • Re-run remote sync

You can see that the assets from the album are not purged from the remote asset table. The same can be tested for a partner sharing. Add a new partner, let the app sync the changes and remove the partner

@alextran1502
Copy link
Member

@zackpollard @jrasm91 Should we also handle this case from the server? Or is this the client's responsibility?

@zackpollard
Copy link
Member

@zackpollard @jrasm91 Should we also handle this case from the server? Or is this the client's responsibility?

We decided that the client needs to do "pruning" when events like this occur. This is because on the server we would have to do quite extensive checks to determine whether an asset is still accessible, so we offload this to the client.

When a relation like this is removed, the client should validate that all assets for example still have a reference in one of the other sharing tables, such as the partner or album tables. A single asset could be available from multiple different methods, so a partner being removed doesn't mean you just need to remove all assets owned by that partner, because they may have shared it with you via an album too, so you may still have access to it.

@alextran1502 alextran1502 requested a review from mertalev October 14, 2025 14:19
@alextran1502 alextran1502 enabled auto-merge (squash) October 29, 2025 14:40
@alextran1502 alextran1502 merged commit cf75ad2 into main Oct 29, 2025
52 checks passed
@alextran1502 alextran1502 deleted the fix/sync-prune-assets branch October 29, 2025 14:41
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.

4 participants