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 d732a63777..bc03d32f8f 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 @@ -90,6 +90,7 @@ class FileUploadWorker( } } + private var currentUploadIndex: Int = 1 private var lastPercent = 0 private val notificationManager = UploadNotificationManager(context, viewThemeUtils) private val intents = FileUploaderIntents(context) @@ -167,7 +168,7 @@ class FileUploadWorker( setWorkerState(user.get(), uploadsPerPage) run uploads@{ - uploadsPerPage.forEachIndexed { currentUploadIndex, upload -> + uploadsPerPage.forEach { upload -> if (isStopped) { return@uploads } @@ -181,12 +182,16 @@ class FileUploadWorker( uploadFileOperation, cancelPendingIntent = intents.startIntent(uploadFileOperation), startIntent = intents.notificationStartIntent(uploadFileOperation), - currentUploadIndex = currentUploadIndex + 1, + currentUploadIndex = currentUploadIndex, totalUploadSize = totalUploadSize ) val result = upload(uploadFileOperation, user.get()) + if (result.isSuccess) { + currentUploadIndex += 1 + } + currentUploadFileOperation = null fileUploaderDelegate.sendBroadcastUploadFinished(