From 878052991c2e60d8e46adf57c0e2bc246dc87928 Mon Sep 17 00:00:00 2001 From: Jonas Mayer Date: Thu, 18 Jan 2024 19:39:14 +0100 Subject: [PATCH] Restart uploads after app restart Signed-off-by: Jonas Mayer --- .../com/nextcloud/client/jobs/upload/FileUploadWorker.kt | 6 +++++- .../java/com/owncloud/android/utils/FilesSyncHelper.java | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt index ef3da622be..2a6c21a1a8 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt @@ -148,7 +148,11 @@ class FileUploadWorker( uploadsStorageManager.getCurrentAndPendingUploadsForAccountPageAscById(lastId, accountName) } - Log_OC.d(TAG, "No more pending uploads for account $accountName, stopping work") + if(isStopped){ + Log_OC.d(TAG, "FileUploadWorker for account $accountName was stopped") + }else{ + Log_OC.d(TAG, "No more pending uploads for account $accountName, stopping work") + } return Result.success() } diff --git a/app/src/main/java/com/owncloud/android/utils/FilesSyncHelper.java b/app/src/main/java/com/owncloud/android/utils/FilesSyncHelper.java index 9944fd2fcf..65545ea7df 100644 --- a/app/src/main/java/com/owncloud/android/utils/FilesSyncHelper.java +++ b/app/src/main/java/com/owncloud/android/utils/FilesSyncHelper.java @@ -44,6 +44,7 @@ import com.owncloud.android.datamodel.SyncedFolder; import com.owncloud.android.datamodel.SyncedFolderProvider; import com.owncloud.android.datamodel.UploadsStorageManager; import com.owncloud.android.db.OCUpload; +import com.owncloud.android.db.UploadResult; import com.owncloud.android.lib.common.utils.Log_OC; import org.lukhnos.nnio.file.FileVisitResult; @@ -173,13 +174,14 @@ public final class FilesSyncHelper { final UserAccountManager accountManager, final ConnectivityService connectivityService, final PowerManagementService powerManagementService) { - final Context context = MainApp.getAppContext(); - boolean accountExists; boolean whileChargingOnly = true; boolean useWifiOnly = true; + // Make all in progress downloads failed to restart upload worker + uploadsStorageManager.failInProgressUploads(UploadResult.SERVICE_INTERRUPTED); + OCUpload[] failedUploads = uploadsStorageManager.getFailedUploads(); for (OCUpload failedUpload : failedUploads) {