Skip to content

Commit 74479e6

Browse files
committed
fix(auto-upload): sync conflict handling
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
1 parent c9dec0d commit 74479e6

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

app/src/main/java/com/nextcloud/client/jobs/autoUpload/AutoUploadWorker.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import com.owncloud.android.db.OCUpload
3737
import com.owncloud.android.db.UploadResult
3838
import com.owncloud.android.lib.common.OwnCloudAccount
3939
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
40+
import com.owncloud.android.lib.common.operations.RemoteOperationResult
4041
import com.owncloud.android.lib.common.utils.Log_OC
4142
import com.owncloud.android.operations.UploadFileOperation
4243
import com.owncloud.android.ui.activity.SettingsActivity
@@ -346,6 +347,12 @@ class AutoUploadWorker(
346347
TAG,
347348
"❌ upload failed $localPath (${upload.accountName}): ${result.logMessage}"
348349
)
350+
351+
// Mark CONFLICT files as handled to prevent retries
352+
if (result.code == RemoteOperationResult.ResultCode.SYNC_CONFLICT) {
353+
repository.markFileAsHandled(localPath, syncedFolder)
354+
Log_OC.w(TAG, "Marked CONFLICT file as handled: $localPath")
355+
}
349356
}
350357
} catch (e: Exception) {
351358
uploadsStorageManager.updateStatus(

app/src/main/java/com/nextcloud/client/jobs/utils/UploadErrorNotificationManager.kt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ object UploadErrorNotificationManager {
8080
result: RemoteOperationResult<Any?>,
8181
notifyOnSameFileExists: suspend () -> Unit
8282
): Notification? {
83-
if (!shouldShowConflictDialog(isSameFileOnRemote, operation, result, notifyOnSameFileExists)) return null
83+
if (!shouldShowConflictDialog(isSameFileOnRemote, operation, result, notifyOnSameFileExists)) {
84+
Log_OC.d(TAG, "no need to show conflict resolve notification")
85+
return null
86+
}
8487

8588
val textId = result.code.toFailedResultTitleId()
8689
val errorMessage = ErrorMessageAdapter.getErrorCauseMessage(result, operation, context.resources)
@@ -176,9 +179,14 @@ object UploadErrorNotificationManager {
176179
return false
177180
}
178181

179-
if (result.code == ResultCode.SYNC_CONFLICT && isSameFileOnRemote) {
180-
Log_OC.w(TAG, "same file exists on remote")
181-
notifyOnSameFileExists()
182+
if (result.code == ResultCode.SYNC_CONFLICT) {
183+
if (isSameFileOnRemote) {
184+
Log_OC.w(TAG, "same file exists on remote")
185+
notifyOnSameFileExists()
186+
} else {
187+
Log_OC.w(TAG, "SYNC_CONFLICT but file not same on remote - no notification needed")
188+
}
189+
182190
return false
183191
}
184192

0 commit comments

Comments
 (0)