-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Storage Migration: Sync before starting storage migration #13356
Storage Migration: Sync before starting storage migration #13356
Conversation
Message to maintainers, this PR contains strings changes.
Read more about updating strings on the wiki, |
a86f5cd
to
ab47dc5
Compare
ab47dc5
to
5c9861c
Compare
70ee216
to
c68a48f
Compare
c260657
to
ab70bdd
Compare
ab70bdd
to
337e791
Compare
val message = """${getString(R.string.migration_update_request)} | ||
<br> | ||
<br>${getString(ifYouUninstallMessageId)}""" | ||
val message = getString(R.string.migration_update_request_requires_media_sync) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A user will now always be logged in
Displays a notification if the app is paused otherwise performs the operation Similar to 'DialogHandler', but doesn't require a dialog
We need to move the user's data to /Android/ to handle scoped storage changes. Before we perform this migration, we should ensure that users data is safe. To do this, we enforce a sync. A user should have completed a full media sync before the migration occurs. This ensures that their data is up to date and can be restored if anything goes awry with the migration Dialog wording as discussed on the Figma, with the exception of changing 'sync' to 'media sync' Issue 5304
337e791
to
885bc11
Compare
We need a media sync before a storage migration. If this has been disabled, it is the user's responsibility to perform a sync before this migration occurs There are currently two reasons: Fetch media on Sync is set to: * 'Only if unmetered' & connection is metered * Never Issue 5304
Caused bugs when performing a storage migration after syncing
If a migration requires a sync, and a sync completes when the app is paused, a notification occurs prompting the user to migrate. This is handled by `DialogHandler`, which runs in AnkiActivity.onResume BEFORE `loadDeckCounts`. This races with closing the collection for a storage migration. Instead, start the task and allow it to be stopped. Issue 5304
885bc11
to
fe5e211
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine - strings are relatively clear (that is: merge-able / cleared out from real translation changes), needs a good second look but is de-conflicted and seems ready to go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the changes and it seems fine to me, so LGTM
I'm going to wait until tomorrow, if Brayan wants to take a look otherwise I'm going to merge it myself.
Given two sets of eyes and the ability to do follow-ons plus the current strings situation (clear: ready to merge) I'm going to go ahead and merge this one and keep the scoped storage train moving down the tracks. Thank you @lukstbit ! |
Purpose / Description
If a user is going to perform a migration, they should be fully synced to ensure no data loss. We can't easily know if they're fully synced on the media side of things, so perform a sync and see.
When the user has performed a media sync, migrate.
The sync may complete while the user has the app closed.
In this case,
withProgress
may not execute (no window), so we conservatively pause the start of the migration until the AnkiDroid window has calledonResume
.Also handle the case where the media sync cannot occur (via
AlertDialog
+ migrate anyway).Fixes
Approach
Define an
AsyncOperation
: similar to anAsyncDialogFragment
, but not necessarily with a dialogDefine a
MigrateStorageAfterSync
It passes this into
sync
, which calls it at the end of the operationDefine a
onSyncCompleted()
listener, as an interface so the sync functionality can be decoupled fromDeckPicker
in future.Handle the activity lifecycle changes in
DeckPicker
, which required a minor rework ofDialogHandler
+AnkiActivity
How Has This Been Tested?
Learning
renderPage()
needs a lot of work for the new BackendChecklist