Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content

feat: Implement device to cloud push for all the files to resolve Murena.io recovery

Fahim Masud Choudhury requested to merge 2985-edrive-murena-cloud-recovery into main

Description

eDrive checks if a recovery is needed and logs out and logs in the user to delete and recreate its database. Because of the recreation of the database, all the files and (syncable) folders are pushed to cloud storage.

When the process completes, a separate SharedPreference is used to track whether recovery is needed or not. It is done so because if a user logs out and logs in from AccountManager, eDrive's initial preference is cleared. However, this recovery preference will not be cleared unless the user explicitly clears eDrive's data.

Technical details

In EdriveApplication's onCreate() method, an instance of RecoverManager initiates the recovery process.

Inside RecoveryManager, it checks whether the recovery is needed using RecoveryPreferences. RecoveryPreferences keeps a separate SharedPreferences which is not cleared when the user logs out and logs in via AccountManager.

For recovery to happen, RecoveryManager logs out and logs in the user consecutively. This process eventually deletes eDrive's database and the default SharedPreferences and then creates them, enabling all the files and folders to be synced again with the cloud.

Tests

To create the before and after scenario of the outage, do the following:

  1. Consult with Fahim Salam to provide a Murena.io dev server to simulate the outage. Alternatively, you can set up a Nextcloud instance on your machine for eDrive and simulate the outage by referring to the study here.
  2. Have files on your phone and sync them with Nextcloud so that you have identical copies of the files on both on eDrive and the cloud.
  3. Disable the Internet on your phone so that eDrive can't connect to the server for a while.
  4. Create some more files and folders on your phone.
  5. Delete all the files and folders from Nextcloud.
  6. Make server return HTTP 5xx error (simulating the outage).
  7. Resume the server to regular operation.
  8. Restore Internet on your phone and observe if eDrive is syncing newly created files during the outage to the server.
  9. At this point, you'll have only the new files in the cloud.
  10. Install the eDrive version from this MR's artifact.
  11. Observe that eDrive will start to push device's files and folders to the cloud.
  12. When the sync finishes, you'll have all the phone's files and folders backed up to the cloud again.

Issues

https://gitlab.e.foundation/e/os/backlog/-/issues/2985

10 commandments of code reviews

👪 ❤️ https://gitlab.e.foundation/internal/wiki/-/wikis/mobile-team/guidelines/Code-review

Edited by Fahim Masud Choudhury

Merge request reports

Loading