Best way to trigger files rescan when new files added to the nextcloud data folder

I have a docker container with nextcloud, and want to set up sonarr and transmission to download/move files into the nextcloud data/files directory of a specific user. I have a docker volume visible in my filesystem with the nextcloud folders, but when I paste some files to /data/username/files/ from my filesystem, they are not recognized/updated in the cloud.

To make it visible I changed file owneship (just in case, it didn’t help on its own) and then did occ files:scan --all, only then the newly added file became visible.

However, a one-time manual scan won’t be enough anyway, so I thought I’d ask:
Is there any existing (or planned) feature that rescans new files based on the filesystem events/changes (when files were uploaded NOT by web or webdav)? Is there a go-to way for thirdparty apps/containers to upload their data to nextcloud on the filesystem level? I suppose nextcloud + download automation + download client is not a very unusual combo.

I know I probably could use something like incron for task scheduling, but maybe I’m missing some better integrated ways?

For what you’re trying to do, it sounds like the best approach would be attaching the folder where sonar and transmission modify files as external storage.

Data that changes in realtime outside of Nextcloud’s control should only be visible to Nextcloud through external storage.

https://docs.nextcloud.com/server/12/admin_manual/configuration_files/external_storage_configuration_gui.html

1 Like

Thanks! At the bottom of that page it is recommended to use cron with External Storage too:
https://docs.nextcloud.com/server/12/admin_manual/configuration_files/external_storage_configuration_gui.html#adding-files-to-external-storages
so I’ll probably setup both external storage and scheduled scans just in case.

Good catch. Have fun!

Cron is recommended for setup for general maintenance tasks, putting data directly into the data folder and running OCC scans can lead to data corruption, so I wouldn’t recommend you do so.

Use external storage and you’ll be fine. You can set it to update on every access and is also how I access my 8TB of server data without having to move/organise it into Nextcloud.

2 Likes

Sorry, I don’t actually use this feature so I didn’t realize that was an option. After another look at the documentation, I see it’s right there in the UI to check for changes on every direct access which I agree is the best way to handle this. :+1:

2 Likes