Merge pull request #12911 from nextcloud/improve-retry-failed-uploads-function

Improve retry failed uploads function
This commit is contained in:
Alper Öztürk 2024-05-02 15:17:01 +02:00 committed by GitHub
commit becdbd6fbe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -124,10 +124,6 @@ class FileUploadHelper {
var uploadUser = Optional.empty<User>()
for (failedUpload in failedUploads) {
// 1. extract failed upload owner account and cache it between loops (expensive query)
if (!uploadUser.isPresent || !uploadUser.get().nameEquals(failedUpload.accountName)) {
uploadUser = accountManager.getUser(failedUpload.accountName)
}
val isDeleted = !File(failedUpload.localPath).exists()
if (isDeleted) {
showNotExistMessage = true
@ -141,10 +137,16 @@ class FileUploadHelper {
canUploadBeRetried(failedUpload, gotWifi, charging) && !connectivityService.isInternetWalled
) {
// 2B. for existing local files, try restarting it if possible
retryUpload(failedUpload, uploadUser.get())
failedUpload.uploadStatus = UploadStatus.UPLOAD_IN_PROGRESS
uploadsStorageManager.updateUpload(failedUpload)
}
}
accountManager.accounts.forEach {
val user = accountManager.getUser(it.name)
if (user.isPresent) backgroundJobManager.startFilesUploadJob(user.get())
}
return showNotExistMessage
}