nextcloud / android

📱 Nextcloud Android app
https://play.google.com/store/apps/details?id=com.nextcloud.client
GNU General Public License v2.0
4.19k stars 1.75k forks source link

Switching accounts deletes synced folder #13348

Open Gerii opened 2 months ago

Gerii commented 2 months ago

⚠️ Before posting ⚠️

Steps to reproduce

  1. Share a file to the Nextcloud app from the share sheet
  2. Go to a folder that has some locally synced files on Account1
  3. Click on Switch account in the top-right menu
  4. Switch to Account2
  5. Account2 will not show up immediately, instead the current folder of Account1 is still shown. However, image previews are missing. The locally synced files in the folder are still on the file system.
  6. Click on the back arrow in the top left.
  7. The whole folder that was open including its files are deleted on the device.

Expected behaviour

Clear the UI before switching the account in the backend logic or show some loading screen (or at the very least, don't delete local folders)

Actual behaviour

Nextcloud app deletes the local folder of Account1 including its files (I assume that the backend logic of the app detects that the folder from Account1 does not exist in Account2 and therefore it deletes it locally). At some point it will either show the content of Account2 or crash before that with a NullPointerException if you click on a folder that exists only on Account1 (see below for NPE).

Android version

14

Device brand and model

Pixel 6 Pro

Stock or custom OS?

Custom (explain in "additional information")

Nextcloud android app version

3.29.1-fdroid

Nextcloud server version

29.0.4

Using a reverse proxy?

No

Android logs

No response

Server error logs

No response

Additional information

No response

Cause of error

Exception in thread "main" java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.owncloud.android.datamodel.OCFile.canWrite()' on a null object reference
    at com.owncloud.android.ui.activity.ReceiveExternalFilesActivity.onCreateOptionsMenu(ReceiveExternalFilesActivity.java:1014)
    at android.app.Activity.onCreatePanelMenu(Activity.java:4595)
    at androidx.activity.ComponentActivity.onCreatePanelMenu(ComponentActivity.java:520)
    at androidx.appcompat.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:95)
    at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.onCreatePanelMenu(AppCompatDelegateImpl.java:3429)
    at androidx.appcompat.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:458)
    at androidx.appcompat.app.ToolbarActionBar$1.run(ToolbarActionBar.java:58)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1406)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1415)
    at android.view.Choreographer.doCallbacks(Choreographer.java:1015)
    at android.view.Choreographer.doFrame(Choreographer.java:941)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1389)
    at android.os.Handler.handleCallback(Handler.java:959)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loopOnce(Looper.java:232)
    at android.os.Looper.loop(Looper.java:317)
    at android.app.ActivityThread.main(ActivityThread.java:8592)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
Gerii commented 2 months ago

Probaly related to https://github.com/nextcloud/android/issues/11022