Nextcloud version: 24.0.4
Operating system and version: Debian 11
Apache or nginx version: Apache 2.4.38
PHP version: 7.4
The issue you are facing:
I have been using Samba/CIFS volumes mounted as users as external storage for a while and it has worked pretty well. However, in the past few weeks, something broke. Even after a full occ files:scan for a user, when they open certain directories, the contents show as empty. However, there should be several files and subdirectories. No specific error is shown in either Nextcloud’s or Samba’s logs.
When a user creates a new file or directory (anything) in one of these folders and then proceeds to reload the page, all other content appears. So it does not seem to be a permission problem: Nextcloud can access these files through samba, but for some reason does not seem to ‘query’ samba when the directory is opened. It seems to assume the directory is empty, without checking, and only checks when there is an update made from within Nextcloud.
I suspect Nextcloud might be maintaining some sort of cache here for these folders? Perhaps as an effect of a previous botched files:scan execution, the folders are remembered as empty. If I am correct, is there a way I could wipe this cache and force Nextcloud to check what files are in these directories when the users open them?
Thanks. I see that there is an occ files:cleanup, but this only seems to remove orphaned cache entries. After execution, it even showed me 0 orphaned file cache entries deleted. I tried a new occ files:scan anyway afterward, but the behaviour is the same: folders show empty when they should have content.
Is there a way to do whatever files:cleanup does but for every file, forcing the cache to be rebuilt?
You can use the -vvv switches to let occ show what it is doing. More important is, that the access rights to the share are correctly set. By default Nextcloud shows all files in a folder independently if it has bee nscanned or not. By default it scans a folder content on the fly. It might be worth to install the SMB connection test app to see what’s going on.
I tried occ files:cleanup with -vvv as well, no output.
Here is something funny though: against recommendations, after taking a backup, I attempted to delete the rows of oc_filecache. This solved the problem: now all files that should be shown are shown, albeit sometimes a reload of the page is needed. But this is already much better than the behaviour before, when Nextcloud would just not show the contents of a folder when permissions are OK and a full scan has been done for the user.
Unfortunately, I found out that regardless of the very obvious hint in its name, oc_filecache is not actually a cache and you are not supposed to alter its contents manually. But it is also true that purging contents helped with the problem I am facing.
I have the same problem. External Storage, SMB, permissions are correct. Most files, folders show correctly, but one folder had no content displaying in Nextcloud. I created a file in this folder through Nextcloud, then suddenly Nextcloud showed all the folder’s content.