[Bug]: Data Loss during External Storage Disconnect
- Dominant language
- C++
- Stars
- 3.9k
- Forks
- 1k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 127
Description
### ⚠️ Before submitting, please verify the following: ⚠️
- [X] This is a **bug**, not a question or a configuration issue.
- [X] This issue is **not** already reported on Github (I've searched it).
- [X] Nextcloud Server and Desktop Client are **up to date**. See [Server Maintenance and Release Schedule](https://github.com/nextcloud/server/wiki/Maintenance-and-Release-Schedule) and [Desktop Releases](https://nextcloud.com/install/#install-clients) for supported versions.
- [X] I agree to follow Nextcloud's [Code of Conduct](https://nextcloud.com/contribute/code-of-conduct/)
### Bug description
# Data Loss during External Storage Disconnect
Firstly, thank you for the awesome Desktop Sync client and Nextcloud in general. I love it. We do however have a small problem to be addressed rather rapidly.
This issue is fairly serious and hits at confidence in sync client behavior which will cause loss of data locally due to a common technical issue of having your external storage device fail or be turned off without turning while still running your Nextcloud instance.
> When the Nextcloud external storage device becomes unavailable, the mount points configured on Nextcloud are unavailable in the back-end with a visible error, but the sync client remains operational - data deletion of all data from the configured local storage will result!
## Hardware and Configuration
* NextcloudPi on a Raspberry Pi 4.
* 2TB raid via USB 3 for external storage.
* Nextcloud v 27.0.1.
* Linux sync client v3.10.0 (KDE).
## Situation
* My raid storage device didn't start due to a suspected power loss during the last 10 days.
* I was running Nextcloud v26.x.x (latest) at this time and the instance stopped functioning completely after power was restored.
* Usually, I manually run the desktop sync client as needed - I didn't use the sync client until I got the instance back online.
* I upgraded to Nextcloud v27.0.1 which brought my instance back online.
* I was working locally on my synced folder for about a week with the sync client **inactive**.
## Result
* I opened the sync client after Nextcloud v27.0.1 was back online, but the external storage was still offline.
* Data loss resulted when the sync client started. All files and folders from the local storage location was removed.
* Inspection of the Nextcloud External Storage configuration showed warnings present about mounting failures of the external storage device, but these warnings were not taken into account by the sync client.
* After mounting the storage device the sync client is now again syncing data locally.
* Any new files created during the offline period and present in the configured sync folder for external storage has been deleted by the sync client and lost.
## Suggestion
* Inspect external storage mounting status before deleting files.
* When deleting files send them to the recycle bin or something similar without simply unlinking files from disc.
* Add a data threshold for deletions e.g. anything over 100 MB of data will require confirmation.
### Steps to reproduce
1. Run Nextcloud v27.0.1.
2. Have external storage connected.
3. Run Sync client with external storage folder to local machine configured and let it sync.
4. Stop/Pause sync client.
5. Create new files in local external storage folder (not on storage device).
6. Disconnect external storage from Nextcloud device (unmount and turn it off while leaving Nextcloud server running).
7. Resume sync client and watch all existing and new data disappear without warning.
### Expected behavior
* Sync client to prompt for large delete operation.
* Sync client to check external storage mounting status before deleting.
* Move files to a "deleted" folder or something such as recycle bin before just removing them.
### Which files are affected by this bug
no_idea.log
### Operating system
Linux
### Which version of the operating system you are running.
Pop!_OS 22.04 LTS
### Package
Appimage
### Nextcloud Server version
27.0.1
### Nextcloud Desktop Client version
v3.10.0 (KDE)
### 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?
- [X] Default internal user-backend
- [ ] LDAP/ Active Directory
- [ ] SSO - SAML
- [ ] Other
### Nextcloud Server logs
_No response_
### Additional info
_No response_
Contributor guide
Research direction
No source file or test is identified; the affected-file field only says no_idea.log. Start by reproducing the seven-step external-storage disconnect scenario described for the Nextcloud Desktop client, then trace how it handles the server's mount-failure warning before local deletion. Done means preventing unreviewed data loss and covering the expected behavior with verification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, linux
- Domain
- backend, desktop
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100