nextcloud / desktop

💻 Desktop sync client for Nextcloud
https://nextcloud.com/install/#install-clients
GNU General Public License v2.0
3.06k stars 804 forks source link

[Bug]: Nextcloud client deletes everything on server #7425

Open HLCaptain opened 4 weeks ago

HLCaptain commented 4 weeks ago

⚠️ Before submitting, please verify the following: ⚠️

Bug description

I host Nextcloud on TrueNas Scale and used it locally. So the host was a local IP (192.168...). I got to make the server accessible remotely under a custom domain to reach it outside my local network.

When I wanted to switch accounts from the local host to remote host with the same account, I got some problems and the client deleted all my files on the server by "syncing". I use Windows and proxied all the files either on the local and remote hosted accounts.

As suggested in this issue comment, I am opening a new issue for my specific problem.

Steps to reproduce

  1. Create a new dummy account with default files.
  2. Add a few files into subfolders, like Documents/School/HomeWork.md
  3. Login to Client with local host account.
  4. Choose proxied files.
  5. Add remote host account.
  6. Choose proxied files with same sync directory as the local host account.
  7. Remove local account (files should remain intact). (might be an optional step to avoid conflicts)
  8. Remote account should sync everything in the directory of the local synced account. As files are proxied, they are not found in the folder and considered as deleted by remote account's perspective. So the remote hosted account deletes the not locally found files in the nextcloud server.

Expected behavior

When the remote account syncs, it does not delete locally not found files on the server.

Which files are affected by this bug

Documents/School/HomeWork.md

Operating system

Windows

Which version of the operating system you are running.

Windows 11 IoT Enterprise LTSC 26100.2161

Package

Official Windows MSI

Nextcloud Server version

30.0.1

Nextcloud Desktop Client version

3.14.2

Is this bug present after an update or on a fresh install?

Fresh desktop client install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

Are you using an external user-backend?

Nextcloud Server logs

No response

Additional info

No response

camilasan commented 4 weeks ago

When I wanted to switch accounts from the local host to remote host with the same account, I got some problems and the client deleted all my files on the server by "syncing". I use Windows and proxied all the files either on the local and remote hosted accounts.

how did you do the switch?

6. Choose proxied files with same sync directory as the local host account.

If I understand you case correctlu, I think this is the reason the files were deleted. Never reuse the sync folder. The database does not get reset for the new sync connection. The client will try to match the database with local and remove, that could lead to deletion of files.

What are proxied files?

HLCaptain commented 4 weeks ago

I have quite a lot files in nested folders (around 5tb), so I guess Windows could not proxy each item. Also I might have not logged into the local account for a while, so files might have changed. I did the switch like:

  1. Local account was there, waiting for connection to sync.
  2. Added remote hosted account.
  3. Chosen local account sync folder.
  4. (Skipped sync configuration by accident, removed remote account and added back again with local account sync folder).
  5. Choose to keep local data from conflict.
  6. Both accounts were present with the same sync folder, local disconnected, remote connected to the host.

I think the remote account started syncing the "new" files and from some point on when I removed the local account it started deleting the not proxied files. There were around 30000 files deleted during a few hours until I noticed.

I tried to replicate it with remote-remote accounts, but the bug did not come up. As I am not on the local network, I cannot replicate this with local-remote hosted accounts.

I guess you are right and I was dumb to reuse the sync folder for the "same" account. I also noticed, that from the authentication flow, the client prompts the user not to reuse the sync folder, but does not prohibit it. I guess it gives the user some freedom, while handling 90% of edge cases with the collision handling, but what I would like to see is an account data migration from a host to another one, seamlessly. Like there would be an option to change the host of a user, who could be identified with a UUID/name with a clear sync path.