Repository navigation
Make sync worker only run when needed - #12372
Conversation
92c29af to
710bad9
Compare
ZetaTom
left a comment
There was a problem hiding this comment.
In my brief testing everything worked as expected. Although I didn't check any edge cases (what happens when a worker is stuck, for example). This might be out of scope for this pull request.
The suggestions are just a minor change and, in reality, just eye candy.
078de3b to
fc33f40
Compare
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
fc33f40 to
c420b5e
Compare
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
b121c21 to
cf8199e
Compare
|
Problem: With current implementation when periodic sync worker is started and immediate filesync is already running because of changed files it will skip periodic sync which is not intended... But it is really unlikely since immediate file sync with changed files should only run for under 1 sec. |
Signed-off-by: Jonas Mayer <[email protected]>
… into make_sync_service_run_only_once # Conflicts: # app/src/main/java/com/nextcloud/client/jobs/FilesSyncWork.kt
Signed-off-by: Jonas Mayer <[email protected]>
alperozturk96
left a comment
There was a problem hiding this comment.
We can get rid of repeated codes in WorkManagerExtensions with this code.
private const val TAG = "WorkManager"
fun WorkManager.isWorkRunning(tag: String): Boolean = checkWork(tag, listOf(WorkInfo.State.RUNNING))
fun WorkManager.isWorkScheduled(tag: String): Boolean =
checkWork(tag, listOf(WorkInfo.State.RUNNING, WorkInfo.State.ENQUEUED))
private fun WorkManager.checkWork(tag: String, stateConditions: List<WorkInfo.State>): Boolean {
val statuses: ListenableFuture<List<WorkInfo>> = getWorkInfosByTag(tag)
var workInfoList: List<WorkInfo> = emptyList()
try {
workInfoList = statuses.get()
} catch (e: ExecutionException) {
Log_OC.d(TAG, "ExecutionException in checkWork: $e")
} catch (e: InterruptedException) {
Log_OC.d(TAG, "InterruptedException in checkWork: $e")
}
return workInfoList.any { workInfo -> stateConditions.contains(workInfo.state) }
}
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
# Conflicts: # app/src/main/java/com/nextcloud/client/jobs/FilesSyncWork.kt
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
alperozturk96
left a comment
There was a problem hiding this comment.
Tested didn't came across with any regression
Signed-off-by: alperozturk <[email protected]>
|
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/12372.apk |

Before in theory 2 sync jobs could run and potentially mess with each other (maybe leads to Excessive file upload conflicts after update to 3.26.0 (not before) #11974)