Round-Sync icon indicating copy to clipboard operation
Round-Sync copied to clipboard

AutoSync/FolderWatch

Open tranzmatt opened this issue 1 year ago • 18 comments

Pre-Submission checklist

  • [X] There is no existing issue that already asks for this feature.
  • [ ] The feature already exists in rclone (on your PC or in Termux)
  • [X] I am prepared to help make this feature

What version of RCX are you using (About -> App version)?

Latest build

What problem are you trying to solve?

Is it possible to have an option that begins a folder watch for the sync and automatically triggers when the contents change? I would like to be able to automatically push pics taken with my camera to a Photoprism WebDav, but there's only the cron version, which isn't as useful.

What should RCX be able to do differently to help with this problem?

A checkbox on the "Trigger" page for starting a FileObserver or NIO task to watch the src folder that automatically fires the sync when a new file (e.g., picture) is written.

I'm not very proficient in Android/Java but would be willing to help.

tranzmatt avatar Mar 07 '23 17:03 tranzmatt

Afaik, this was not really possible on android because of the more modern limitations of androids filesystem handling.

Also it requires the app to be permanently running in the background.

It would be more easy to regularly start a sync, as in an interval-option instead of time-based only. Would that fit your usecase?

newhinton avatar Mar 12 '23 15:03 newhinton

Afaik, this was not really possible on android because of the more modern limitations of androids filesystem handling.

Also it requires the app to be permanently running in the background.

It would be more easy to regularly start a sync, as in an interval-option instead of time-based only. Would that fit your usecase?

Agreed, the majority if not all sync apps are interval based on Android 10+ I'm willing to test interval feature and compare it to schedule in terms of delay with battery optimization on.

TalalMash avatar Mar 19 '23 20:03 TalalMash

I have started working on intervals. The ui and model are more or less already done, but i will have to implement and test the actual running of an interval.

For now i have limited intervals to a predefined set of 15, 30, 60 and 120 minutes. I can easily add more intervals, but making it custom would be a lot of work ui-wise that i will not do for a first prototype.

newhinton avatar Mar 20 '23 13:03 newhinton

You can test interval-syncing here now!

newhinton avatar Mar 22 '23 14:03 newhinton

It should be noted that the current release has a bug, where a disabled trigger will not actually be disabled. A full device restart is reqired to clear out the stuck trigger. This behaviour has been fixed on the current master branch ~~, but i did not create a seperate release for this (yet).~~

newhinton avatar Mar 22 '23 18:03 newhinton

Thank you will report over 2 days of various usage. (& on multiple phones/OS-versions)

TalalMash avatar Mar 22 '23 19:03 TalalMash

Screenshot_20230322_234352 9/10 times it works, this is probably caused by Wi-Fi or battery saving, a retry interval may be useful, will try next with battery optimization disabled.

This is done with 15 minute interval for testing, and it successfully files every 12-25 minutes on average, also it synced fine even while ignoring this error after 15 mins.

TalalMash avatar Mar 22 '23 20:03 TalalMash

Yeah the interval-deviations are expected and not really something we can prevent. Android batches jobs together to save battery and this causes the deviation.

Regarding wifi, is it possible that your device actually disconnects when it is idle? then this would be working as intended. You can check that with pinging your phone from your pc while your phone is idle.

newhinton avatar Mar 22 '23 21:03 newhinton

An option to retry a failed task after 5 minutes may be an idea, however i think it would be a good idea to make it app-wide for tasks, not a per-task setting.

newhinton avatar Mar 22 '23 21:03 newhinton

Possibly, connectivity check may be useful too, or have different levels of errors for notifications. Here is a ping every minute to the phone idling, not sure if that would keep it awake though: image It rarely happens, anyways it's working really well so far and in a timely manner with no noticeable battery drain despite the 15min interval.

TalalMash avatar Mar 22 '23 23:03 TalalMash

Sync service and Sync service success notification seem to be the same, I had to disable both to suppress the many messages with the 15min interval.

TalalMash avatar Mar 22 '23 23:03 TalalMash

Sync service and Sync service success notification seem to be the same, I had to disable both to suppress the many messages with the 15min interval.

Yeah i guess those dont work properly. The idea is that the summary-notification dismisses the single-run notifications, so that only one notification is shown for multiple syncs. I will have to rethink notifications.

newhinton avatar Mar 23 '23 08:03 newhinton

Sorry for being away from the thread. I'm a little confused. I have other apps that auto-upload things, like Onedrive and Amazon photos, though I can restrict them to unmetered connections like WiFi. What are they doing that allows it or are you saying they're interval based too? My needs are more real time and would go to other storage containers like S3.

tranzmatt avatar Mar 23 '23 19:03 tranzmatt

What are they doing that allows it

I simply dont know. They probably use FileObserver in a service. However, implementing a FileObserver-Service is quite a bit more elaborate than intervals, so i did them first.

Also both of them have nothing to do with unmetered or metered connections, that is a different thing altogether and is not really important to this issue.

newhinton avatar Mar 24 '23 09:03 newhinton

Currently extRact app exits once I select a directory for sync from local to remote (release 2.1.1 with rclone 1.61.1). Is this related to this issue here or is this another one?

It just closes the app and the logs are still empty.

@newhinton is there any way of helping debugging it?

alexanderadam avatar May 07 '23 09:05 alexanderadam

Currently extRact app exits once I select a directory for sync from local to remote

I've noticed the same. However, everything works when creating a task so that can be used as a workaround for now. Edit: you can always try to debug using Android Studio and see what the exception is, or look at the Logcat and submit a bug with the exception content, or create a separate issue for someone else to debug.

alensiljak avatar Jun 09 '23 11:06 alensiljak

What sync exactly do you mean? (Also is this present with the 2.1.3 version?) I am not entirely sure how to trigger that bug, could you write down which steps i need to do? Bonus points if you open a new issue for it ;)

newhinton avatar Jun 09 '23 12:06 newhinton

Afaik, this was not really possible on android because of the more modern limitations of androids filesystem handling.

Also it requires the app to be permanently running in the background.

It would be more easy to regularly start a sync, as in an interval-option instead of time-based only. Would that fit your usecase?

I would also love an option to watch for folder changes, instead of manual or time-based.

I don't think requiring the app to run in the background is an issue, but very expected.

mfferreira avatar Nov 24 '23 14:11 mfferreira