How to rescan an externally modified folder in Nextcloud from a custom app?

Hi everybody.

In short:
How to simulate the command “sudo -u www-data php occ -v files:scan %userid% --path="/%userid%/files/Folder/” from inside a custom Nextcloud app. Is that possible?

In long
I’ve made an app for Nextcloud that runs an external process (binary) which in turn generates some files in a user folder.
The problem is that Nextcloud is unable to list those files until I run the “files:scan” command from the “occ” manually.
But in order to run “occ” I need access to the server terminal or run the command in a cron, which is not the most efficient way to do this.

I was wondering if Nextcloud has some Class or API that I can run to rescan a folder from within my Nextcloud app for the current user.

Any help is highly appreciated.
Greetings and thanks.

1 Like

see here, what file:scan does


I am really interested by the solution you may have found (or not) :slight_smile: Could you explain ?