Local files deleted if External Storage fails to mount

Nextcloud version: 23.0.4
Operating system and version: Debian 11.3
Apache or nginx version: Apache/2.4.53
PHP version: 7.4.28

The issue you are facing:
If Local type External storage gets dismounted (or not mounted correctly on server restart) than the local copy of the folder gets deleted when the folder is refreshed (for example trying to write new file into that folder).

Steps to replicate it:

  1. mount SMB/NFS share to /mnt/external
  2. add External storage type “Local”
  3. synchronize added folder with Windows NextCloud client
  4. unmount SMB/NFS share
  5. trigger an update (example: create a new file in the external folder in web client or upload file from mobile) or just wait for update to happen
  6. Windows NextCloud client will delete local copy of the folder / subfolder

The output of your Nextcloud log in Admin > Logging:

Error	index	OCP\Files\NotFoundException: /peter/files/Test/Peter

    /var/www/cloud/lib/private/Files/Node/Node.php - line 286:

    OC\Files\Node\Root->get()

    /var/www/cloud/apps/recommendations/lib/Service/RecentlyEditedFilesSource.php - line 57:

    OC\Files\Node\Node->getParent()

    <<closure>>

    OCA\Recommendations\Service\RecentlyEditedFilesSource->OCA\Recommendations\Service\{closure}("*** sensiti ... *")

    /var/www/cloud/apps/recommendations/lib/Service/RecentlyEditedFilesSource.php - line 65:

    array_map()

    /var/www/cloud/apps/recommendations/lib/Service/RecommendationService.php - line 90:

    OCA\Recommendations\Service\RecentlyEditedFilesSource->getMostRecentRecommendation()

    <<closure>>

    OCA\Recommendations\Service\RecommendationService->OCA\Recommendations\Service\{closure}("*** sensiti ... *")

    /var/www/cloud/apps/recommendations/lib/Service/RecommendationService.php - line 91:

    array_reduce()

    /var/www/cloud/apps/recommendations/lib/Controller/RecommendationController.php - line 70:

    OCA\Recommendations\Service\RecommendationService->getRecommendations()

    /var/www/cloud/lib/private/AppFramework/Http/Dispatcher.php - line 217:

    OCA\Recommendations\Controller\RecommendationController->index()

    /var/www/cloud/lib/private/AppFramework/Http/Dispatcher.php - line 126:

    OC\AppFramework\Http\Dispatcher->executeController()

    /var/www/cloud/lib/private/AppFramework/App.php - line 157:

    OC\AppFramework\Http\Dispatcher->dispatch()

    /var/www/cloud/lib/private/Route/Router.php - line 302:

    OC\AppFramework\App::main()

    /var/www/cloud/lib/base.php - line 1008:

    OC\Route\Router->match()

    /var/www/cloud/index.php - line 36:

    OC::handleRequest()

No errors in apache logs.

I consider this a severe bug that actually kills the feature.
Of course we always need to assume that the mount might not be working.
This problem is even more severe if the external storage is mounted as root - in case of a broken SMB/NFS connection the content of the old files directory is displayed and can be accessed.

If the network connection gets broken our we have a special reboot situation, nextcloud must not start using wrong files or erase files.

Same problem here:

  • Nextcloud Hub 6 27.1.0
  • SMB configured as External Storage. Details: the external storage is configured as “/” folder for all users. So all users, when logged-in, look at the entire SMB share content (we don’t need data segregation across users).
  • Windows clients on the latest version and configured to locally synch all the files (the entire SMB share content)

If the SMB storage gets unreacheable (power/network loss) the local folders on windows are destroyed.

When it happens the NC server, of course, logs a lot of SMB errors and, when the SMB is back again, it mounts it again and, on server side, everything is fine and all files are available.
On the windows client side. instead, the local folders are destroyed forever and the only way to have local files again is to remove and re-create the sync (waiting 8 hours for the new synchronization).

What’s the reason to have local files if they are unavailable (and destroyed) every time the remote files are not available?

One additional detail: if users log-in on the webclient during an external storage outage they don’t see the external storage content (of course, it’s unavailable) but instead they see the “nextcloud default files”. It’s like if the systems reverts back to the “standard NC user data folder” when the external storage, mounted as users’ “/”, is unavailable.
So I guess than when the user “/” is mapped to an external storage and it becomes unavailable, the systems maps it back to the local NC user folder, and this completely breaks the local synchronization.

Is anyone able to reproduce or support on this?