Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on feddit.org
nextcloud·NextcloudbyMoLoPoLY

External Storage - Check for changes

Im using a External Storage folder to hold my markdown notes. I only use them sporadically via Nextcloud and view/change them mostly via external applications. But i have to rely on the Nextcloud WebDAV sync to sync the to some devices. When i now change such a note externally, this change doesnt sync to the devices. Nextcloud means, that the files have not changed. Only when I open one of the edited notes the change will be detected, and then the WebDAV sync works.

In the adminpanel i have set the option for this external storage in "Check for changes" to "Once every direct access". I can also set it to "Never". Both settings are documented. But there is also a setting "Ever". This is not documented in https://docs.nextcloud.com/server/stable/admin_manual/configuration_files/external_storage_configuration_gui.html

Unfortunately, "Always" doesn't necessarily mean "Immediately." When I select "Always," the WebDAV sync still hasn't completed even after 10 minutes.

So where does this “Always” come from if it’s not documented anywhere, and what does it mean? And even more importantly, how do I get a WebDAV sync to work after making a change? Do I really have to run occ files_external:scan <id> every few seconds?

View original on feddit.org
4

8 replies

piefed.zip

When i now change such a note externally, this change doesnt sync to the devices

Could you expand on your setup?

When you are editing the file, let's say on Desktop, that file is under Nextcloud Client sync, right? Or not?
If not, how do you update the files in Nextcloud? Via webDav? Or just copy over sftp/syncthing?

1
MoLoPoLYreply
feddit.org

On the Desktop I'm using Obsidian and sync via rsync. On Android also Obsidian, but sync via WebDAV. On the web im using my own plug-in for roundcube and edit it directly on the external storage

1
INeedManareply
piefed.zip

Ah, that will be a problem. For NC to reliably notice the changes the files have to go through it. So on desktop set up Nextcloud client for syncing those files, or sync via webDav (maybe it could be set up in Obsidian? It is possible Logseq). On the web, either change roundcube to go through NC, or as you suggested, run the scanning after each session

EDIT: https://docs.nextcloud.com/server/stable/user_manual/en/files/external_storage.html#file-change-detection

1
MoLoPoLYreply
feddit.org

For me, WebDAV is just a workaround, since it’s the only way I can sync files even without Wi-Fi and while on the go. But here’s an idea: Is there a way to send some kind of webhook to Nextcloud that would trigger the scan? Then, after editing in Roundcube or running an rsync, I could send a REST request that would initiate the scan. Since I developed the Roundcube plugin myself, I can integrate that whenever I want and, if necessary, delay it to capture multiple changes. Of course, this only works if there’s a corresponding feature in Nextcloud.

1
INeedManareply
piefed.zip

I don't think the scan is somehow exposed via API. But maybe NC flow could be set up for that?
There's also NC ExApps. And I guess you might set something like that using push. Either ntfy or NC push

1

Many thx. As a workaround, i have now created 2 systemd units:

Service Unit: nc_scanfolder.service

[Unit]
Description=Starts scanning the folder
After=network.target

[Service]
Type=oneshot
User=www-data
ExecStartPre=/usr/bin/sleep 10
ExecStart=/usr/bin/php /var/www/nextcloud/occ files:scan --path="/username/files/folder"

and Path Unit: nc_scanfolder.path

[Unit]
Description=Checks for changes

[Path]
PathChanged=/mnt/external/storage/folder
Unit=nc_scanfolder.service
TriggerLimitIntervalSec=30
TriggerLimitBurst=1

[Install]
WantedBy=multi-user.target

This works fine so far. If a file changes in this folder, the scan will be initialized. To prevent running the scan to often for to much changes, i have added a delay of 10 seconds in the service unit and a burst limit in the path unit. With this, multiple changes are bundled in 1 scan. At least, its a workaround. I dont know if there are better ways to do this.

2

You reached the end