Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Run sync job only when files are created or changed #1102

Open
plantroon opened this issue Mar 19, 2024 · 6 comments
Open

Comments

@plantroon
Copy link

Nextcloud app has a feature, which allows it to run file sync when files are created/changed in a directory and otherwise be inactive - thus consume almost zero battery.

Could the same interfaces be used to implement a feature like that in syncthing? Meaning it runs when and only if a new file appears (or changes) in the specified directories on the phone.

This way, photos/screenshots would be immediately uploaded, but the app remains otherwise inactive. Same as the Nextcloud app does it. IIUC not even active connection to the server needs to be kept for this to work.

This would be an even bigger battery saver than running the sync once an hour.

@Catfriend1
Copy link
Owner

Hi,

This is a cool idea. Had this years ago, but refrained to implement it because we would miss a notify mechanism where a device partnered with the phone could trigger it to start syncthing because their files changed. If only one side does this efficient file watching to trigger sync , here the phone, you could easily produce a lot of conflicts if the user does not fully understand what is going on there.

@plantroon
Copy link
Author

What if it worked if you only had send -only folders configured? Or if the option came with the appropriate warning?

For me it is very practical that Nextcloud only ever does anything when new files appear and it's been very reliable over the years that any photo I take appears on my server and laptop within seconds

@Catfriend1
Copy link
Owner

That may work tying it to sendOnly. What I still don't know exactly after years on this... How much battery does a full startup (and scan) consume vs. leaving SyncthingNative always running in the background?

I guess, native processes on Android may lack some battery saving optimization , as the OS does not know what the native will want to do next and morelike treats like its own crucial-to-operation builtin processes. But that's unfortunately the nature of thr cross built Syncthing .

@plantroon
Copy link
Author

I am not sure about Android's capabilities, but maybe a sigstop/sigtstp could be sent to the process?

@plantroon
Copy link
Author

There is one more significant use case for this - when you are in areas with bad signal coverage, but otherwise want to have your photos/vids uploaded on LTE automatically as they're taken, Syncthing will massacre the battery life by trying to reconnect even if you aren't taking photos. The phone just dies like this.

Or when travelling and changing networks a lot - each change causes Syncthing to attempt reconnects and thus kills battery like there's no tomorrow.

@sjpatel21
Copy link

This options seems worth exploring specifically for SendOnly. As I would assume that would be more prevalent option for the android devices, and the battery savings might be worthwhile to pursue this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants