"Could not open file" - inconsistent database?


I’m facing a problem with the Nextcloud server, which hints at a
inconsistency between the file system in /var/www/html/nextcloud/data/v/files and Nextcloud metadata.

I have some files, which are listed in the web interface, but are not present in the file system. Of course, you can’t open them. Access to such a file leads to these two errors in the server’s log:

Fatal webdav Sabre\DAV\Exception\ServiceUnavailable: Could not open file

Error PHP fopen(...): failed to open stream: No such file or directory at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#301

How do I get a clean system again? Can Nextcloud’s database be rebuilt?

The Nextcloud Server version is 16.0.3, the Desktop Client version is 2.6.4git. The operation systen is Ubuntu 18.04 LTS. The apache version is 2.4.29.

It’s the first time you’ve seen this error.

I can’t provide steps to replicate it, because it is specific to my machine.