How to make nextcloud aware of added files

I’m running Nextcloud 11 on a raspberry pi 3 (raspbian jessie) with apache and mariadb. I had a zip-file in the Photos directory of my Nextcloud-account and wanted to unzip it, I logged in to the raspberry with ssh and unzipped the file there, but when I log in my Nextcloud account now, I don’t see the unzipped files in my Photos directory. How should I make Nextcloud aware of the new situation?

kind regards,
hugo

1 Like

https://docs.nextcloud.com/server/11.0/admin_manual/configuration_server/occ_command.html#file-operations

The occ files:scan command listed in the docs above :thumbsup:

2 Likes

And add beside username --unscanned to just scan the new files, and reduce time therefore.

You could also add
'filesystem_check_changes' => 1,

to your config.php as described here

‘filesystem_check_changes’ => 0,

Specifies how often the local filesystem (the Nextcloud data/ directory, and NFS mounts in data/) is checked for changes made outside Nextcloud. This does not apply to external storages.

0 -> Never check the filesystem for outside changes, provides a performance increase when it’s certain that no changes are made directly to the filesystem

1 -> Check each file or folder at most once per request, recommended for general use if outside changes might happen.

5 Likes

Thanks for your help, unfortunately I get the message below when trying the command:
sudo -u www-data php occ files:scan --path="/ramon/files/Photos"

Could not open input file: occ

Should I install something extra?

kind regards,
Hugo

You have to give the full path to the occ file in your nextcloud directory:
sudo -u www-data php /path/to/nextcloud/occ files:scan --path="/ramon/files/Photos

1 Like

Thanks for the reply, after a “chmod +x /var/www/nextcloud/occ” I could execute the command like this:
sudo -u www-data /var/www/nextcloud/occ files:scan --path="/ramon/files/Photos"

worked like a charm!

kind regards,
Hugo

This does not work for mounted drives (external drive app or virtual mounted drives like rclone). I wish this worked.

You mean the –unscanned option? How did you test?

Hmm, in theory it should work just the same since file cache entries are present for external storage content as well (probably with exceptions). However, if its not locally mounted, the time savings benefit might be small when getting the file list takes much longer then scraping data and updating the related database entry, not sure, depends on protocol as well I believe, or how the external drive app retrieves file list/info in general.

–unscanned works but it doesn’t find any entry to update. It lists 0 new files. It only see new files if you use the scan --all option, which is very bad in performance and can corrupt files.

And are you sure that there are indeed new files that have not yet been added to the oc_filecache database? And this is true for local mounts/paths as well, just invoked via external storage app?

Probably the way the external storage app “walks” through files implies that it makes no difference (in how the files are accessed) between only getting the name/path to check for oc_filecache entry and getting all info required to create a new entry. It then makes doubled sense that this check is not included as regular background job (filesystem_check_changes).
However then this would be something to add to the documentation: https://github.com/nextcloud/documentation

The example file isn’t available anymore. Any chance you could clarify where exactly this change should be made?
Thanks

Here is the documentation for the latest nextcloud version