Skip to content

Conversation

@abelgardep
Copy link
Contributor

@abelgardep abelgardep commented Sep 29, 2021

Related Issues

App: #3327

Library PR (if needed): owncloud/android-library#436


QA

Test plan: https://github.com/owncloud/QA/blob/master/Mobile/Android/Release_2.19/Scoped%20Storage%20Migration.md

Reports:

@abelgardep abelgardep self-assigned this Sep 29, 2021
@abelgardep abelgardep linked an issue Sep 29, 2021 that may be closed by this pull request
14 tasks
Copy link
Collaborator

@JuancaG05 JuancaG05 left a comment

Choose a reason for hiding this comment

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

Some tiny suggestions @abelgardep, great job! 💯

Copy link
Contributor

@fesave fesave left a comment

Choose a reason for hiding this comment

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

Great job!!! Congratulations!!! 🥇

Copy link
Collaborator

@JuancaG05 JuancaG05 left a comment

Choose a reason for hiding this comment

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

💯

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 5, 2021

(1) [WONT FIX]

  1. Display the wizard (by upgrading from prev version)

Current: in 1st slide, the Learn more points nothing

Expected: Learn more should point somewhere. If there is no a suitable way to point (complex or very technical information, or something not very friendly), i think we should remove it.

Pixel 2 Android 11
7253e2ae

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 5, 2021

(2) [WONT FIX]

How important is the Remind me later link in 1st slide? it is missing. Check here the mock up. Which is the expected behaviour? As @tbsbdr:

For those people, who really need the legacy storage-option for a longer transition period (until all apps migrate to the scoped storage) we should provide an option for them to postpone the migration to a convenient later time. I think we should be polite with our wizard and show it eg. only every 7 days (and also have the opportunity to start it directly form the settings). So the basic idea is: With postponing the migration a little bit, we buy some time for those people who still rely on legacy storage and eg. wait for soped-storage-upades for their eg. fancy pdf viewer.

How complex is this to implement? Is it technically correct keep using legacy storage when the app points to Android 11 SDK?

The "longer transition period" should not be very long, because all apps must do the update. Therefore, if we have to implement a complex logic to delay the migration, it would not be worthy because they will be updated soon.

More ideas welcome.

@abelgardep
Copy link
Contributor Author

Related to (2), if we have a remind me later it adds more potential error cases.

Imagine that you do want to perform the migration later, new files will be downloaded to the scoped storage. Maybe there are some with the same hierarchy in the legacy one. After that, if we try to migrate, those files to scoped storage, some conflicts could appear.

We won't have full control over the files if we add a remind me later option

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 5, 2021

Related to (2), if we have a remind me later it adds more potential error cases.

Imagine that you do want to perform the migration later, new files will be downloaded to the scoped storage. Maybe there are some with the same hierarchy in the legacy one. After that, if we try to migrate, those files to scoped storage, some conflicts could appear.

We won't have full control over the files if we add a remind me later option

Is this ok for you to skip the "Remind later" option and perform migration just in the moment of the app upgrade? @theScrabi @michaelstingl @tbsbdr @JuancaG05 @fesave

Pros of removing "Remind me later": easier technically to implement (already done). Don't letting user to decide is straightforward and avoid confusions. Only one direction.

Pros of keeping "Remind me later": user decides when to upgrade.

Contras of keeping "Remind me later": More work to do, closer to the deadline. Users will have to wait for other apps to implement SAF inside (from November on, without Scoped Storage and SAF, not posible to update in Google Play) and could forget to trigger the migration. Conflicts can happen, because we will not maintain the legacy data anymore, causing a bigger problem.

@michaelstingl
Copy link
Contributor

Pros of removing "Remind me later": easier technically to implement (already done). Don't letting user to decide is straightforward and avoid confusions. Only one direction.

I also prefer the simplicity of this approach.

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 5, 2021

(3)

Check this out:

When the wizard is displayed after upgrading:

  • If the app is killed, when it is opened again, the wizard is again there. ✅
  • If the device is switched off/rebooted, by opening again the app, migration is not done and wizard not displayed. New downloads are done correctly, but downloaded stuff before is lost.

As this is a corner case, it could happen only in case the device is running out of battery (we can guess the user will not power off the device at this moment). From my side, it does not make sense to develop a mechanism to prevent such scenario, but it could be interesting to add in the first slide a recommendation like "please don't switch your device off. If your battery is low, please plug it on before continuing the process"

what do you think?

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 5, 2021

(4) [FIXED]

  1. Install previous version and add one account
  2. Set some stuff as av. offline (not needed a big amount)
  3. Migrate to new version (no matter if cleaning or keeping)

Current:

When the migration finishes, all av. offline files and folder are queued in uploads view to upload to the server

Expected:

Nothing changed, nothing should be uploaded

Pixel2 Android11
7253e2aee

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 5, 2021

Question -> Are log files migrated? @abelgardep

@abelgardep
Copy link
Contributor Author

abelgardep commented Oct 6, 2021

Question -> Are log files migrated? @abelgardep

Yes, they should, right? The point here is that in 2.18.1, logs are not stored inside a logs folder, they were directly in the root folder and they are migrated to the root folder instead of a logs folder and they won't be detected by the logs collector 🤔

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 6, 2021

This is the status after a migration:

Screenshot 2021-10-06 at 09 02 10

the log file in owncloud root is migrated from the legacy storage, but, a new one is created inside /logs.

@abelgardep
Copy link
Contributor Author

(4)

  1. Install previous version and add one account
  2. Set some stuff as av. offline (not needed a big amount)
  3. Migrate to new version (no matter if cleaning or keeping)

Current:

When the migration finishes, all av. offline files and folder are queued in uploads view to upload to the server

Expected:

Nothing changed, nothing should be uploaded

Pixel2 Android11 7253e2aee

Migrating the files from legacy to scoped storage, at the moment, does not preserve copied file attributes such as creation/modification date, permissions, etc.

This is a problem for the AvOffline service since it compares the last modification timestamp in the local file with the last time we get data from the server. It means that it detects that something changed in the local storage and it enqueues a new upload.

There are two potential ways to fix this.

  1. Find a way to migrate the files keeping the local attributes.
  2. Alter the current AvOffline service so it won't need to enqueue new uploads when a local file changes.

The second one could be a good option since we will store the files in the scoped storage and other apps won't be able to modify them. The only way to modify files within scoped storage will be using the documents provider and it already performs a synchronization.

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 6, 2021

(5)

  1. Download a big amount of files, so that the remaining space in the device is less than the space these files occupy
  2. Migrate with "keep"/"clean" option -> no enough space

Current:

device runs into disk issues, and finally the app crashes

2021-10-06 09:53:19.727 29884-29925/? E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1
    Process: com.owncloud.android.debug, PID: 29884
    java.io.IOException: write failed: ENOSPC (No space left on device)
        at libcore.io.IoBridge.write(IoBridge.java:501)
        at java.io.FileOutputStream.write(FileOutputStream.java:316)
        at kotlin.io.ByteStreamsKt.copyTo(IOStreams.kt:108)
        at kotlin.io.FilesKt__UtilsKt.copyTo(Utils.kt:237)
        at kotlin.io.FilesKt__UtilsKt.copyTo$default(Utils.kt:217)
        at kotlin.io.FilesKt__UtilsKt.copyRecursively(Utils.kt:328)
        at kotlin.io.FilesKt__UtilsKt.copyRecursively$default(Utils.kt:291)
        at com.owncloud.android.data.storage.LocalStorageProvider.copyFileOrFolderToScopedStorage(LocalStorageProvider.kt:143)
        at com.owncloud.android.data.storage.LocalStorageProvider.copyLegacyToScopedStorage(LocalStorageProvider.kt:124)
        at com.owncloud.android.presentation.viewmodels.migration.MigrationViewModel$copyLegacyStorageToScopedStorage$1.invokeSuspend(MigrationViewModel.kt:73)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
     Caused by: android.system.ErrnoException: write failed: ENOSPC (No space left on device)
        at libcore.io.Posix.writeBytes(Native Method)
        at libcore.io.Posix.write(Posix.java:273)
        at libcore.io.BlockGuardOs.write(BlockGuardOs.java:319)

Is there any way to prevent the keep option if there is no enough space in the device?

7253e2ae

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 6, 2021

There are two potential ways to fix this.

  1. Find a way to migrate the files keeping the local attributes.
  2. Alter the current AvOffline service so it won't need to enqueue new uploads when a local file changes.

I'd go for 2, if the following steps pass:

  1. Open oC file with external app that also supports SAF
  2. Modify and save the file
  3. File is saved in oC server

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 6, 2021

(6) [FIXED]

as discussed above

Yes, they should, right? The point here is that in 2.18.1, logs are not stored inside a logs folder, they were directly in the root folder and they are migrated to the root folder instead of a logs folder and they won't be detected by the logs collector 🤔

we'd go for an approach in which log files (out of the logs folder) will not be migrated. Log files are removed after a week and the content could be reproduced again. Otherwise, old logs will not be removed by the logs collector.

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 6, 2021

(7) [FIXED]

Small typo?:

Screenshot 2021-10-06 at 18 28 55

safer would sound better. ;)

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 6, 2021

(8)

Finished uploads are lost in the uploads view after migrating, that means:

  1. Install previous version
  2. Perform some correct uploads -> they will appear as finished in the uploads view
  3. Upgrade to this branch

Current:

Uploads view is empty

Expected:

Finished uploads in the list

Is there any regard in the migration? afaik, the list of finished uploads is stored in DB.

Nexus 6P v7
7253e2ae

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 7, 2021

About (6)

With commit bb166e2 , separated files are not migrated anymore. But, i saw that the migrated folders do not follow the expected hierarchy. Check the 10GB_10files folder inside the Scoped Storage:

Screenshot 2021-10-07 at 08 31 50

folder with all the stuff hangs from owncloud instead from the account folder.

@abelgardep
Copy link
Contributor Author

(8)

Finished uploads are lost in the uploads view after migrating, that means:

  1. Install previous version
  2. Perform some correct uploads -> they will appear as finished in the uploads view
  3. Upgrade to this branch

Current:

Uploads view is empty

Expected:

Finished uploads in the list

Is there any regard in the migration? afaik, the list of finished uploads is stored in DB.

Nexus 6P v7 7253e2ae

Yes, I clean the finished uploads when migration is done. That way I just need to update where the pending uploads are stored.

@abelgardep abelgardep force-pushed the feature/scoped_storage branch from 2a6a99a to 46f0deb Compare October 7, 2021 07:27
@abelgardep abelgardep force-pushed the scoped_storage_migration branch from bb166e2 to 818a5a9 Compare October 7, 2021 07:34
@abelgardep
Copy link
Contributor Author

Related to (5): Two scenarios

  • No local space to migrate and keep For example, 20 Gb of owncloud data and 12Gb free space left. We are not able to keep legacy and scoped storage. No Migrate and Keep option could do the work.
  • No local space to move a huge file in the Migrate and Clean option. For example, a 7Gb video, total owncloud data: 10Gb but 5Gb free space. We could try to migrate everything but the huge file.

@abelgardep abelgardep force-pushed the feature/scoped_storage branch from 46f0deb to 24621a6 Compare October 22, 2021 10:13
@abelgardep abelgardep force-pushed the scoped_storage_migration branch from 43168bd to bd89c41 Compare October 26, 2021 11:05
@tbsbdr
Copy link

tbsbdr commented Oct 27, 2021

Text for version without "Keep old data"

Plaintext

(thx @mcarioscio-ownCloud for your review!)
Here comes some polished text. Also if we dont offer an option to keep old files, it must say "... files will be cleaned ..." (2nd screen)

Updated Text is italic

Text:

  1. Your app has been updated. This app update migrates your files to a more secure location on your device. This one-time data migration is required and can take up to a minute or more.
  2. Found 2.6 GB of data on your external storage. It will be moved to the safe storage on your device. Remaining files will be cleaned from your external storage after the migration to avoid duplicates and vulnerability.
  3. Migrating your files. Please don’t turn your device off.
  4. Migration completed successfully. Your files are now safer than ever before.

image

@abelgardep if the text is okay for you, could you please update the text in the wizard?

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 28, 2021

Regarding (5), i ran into space issues

  1. Device has 8 GB free
  2. Download 5GB inside the oC account (now 3GB left). I used 5 files 1GB each
  3. Perform migration

Current: app crashes. After the crash:

  • Legacy storage: all the files are there.
  • Scoped Storage: 3 files copied

It seems that the old files were not removed at the time they were totally copied.

Expected: every file is copied to Scoped Storage and then, removed from legacy storage.

Nexus6P Android7
01a9fba8e

@jesmrec
Copy link
Collaborator

jesmrec commented Oct 29, 2021

(11)

  1. Set two accounts in old version
  2. Download files in both accounts
  3. Migrate to this version

Current: some downloaded files are displayed as repeated.
Expected: no repetitions

Pixel2 v11
Nexus6P v7

723f3bd8

@jesmrec
Copy link
Collaborator

jesmrec commented Nov 2, 2021

Regarding (5)

With the latest commit 135e682 i have performed the following steps:

9GB available in device
Download a 5GB file and two 1GB files

So, we have only ~2GB available

Migration

After migration:

5GB file is downloaded (green mark)
1GB files are not downloaded (no green mark)

But, checking the Device explorer:

1GB files are complete
5GB file is not complete (1.8GB)

is there any way to remove pieces of file that were not totally migrated?
why is green mark in the file that was not totally migrated and not in the ones migrated?

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 2, 2021

@jesmrec
Copy link
Collaborator

jesmrec commented Nov 3, 2021

Everything fixed, ready to go!

@abelgardep abelgardep merged commit 6fcf701 into feature/scoped_storage Nov 3, 2021
@abelgardep abelgardep deleted the scoped_storage_migration branch November 3, 2021 17:06
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.

[FEATURE REQUEST] Scoped Storage Migration from legacy storage

7 participants