Merge pull request #14162 from nextcloud/bugfix/upload-current-file-index

BugFix - Upload Current File Index
This commit is contained in:
Tobias Kaminsky 2024-12-16 09:36:14 +01:00 committed by GitHub
commit 907cd130e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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