Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve retry failed uploads function #12911

Merged
merged 6 commits into from
May 2, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,9 @@ class FileUploadHelper {
val isPowerSaving = powerManagementService.isPowerSavingEnabled
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
Expand All @@ -141,10 +139,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
}

Expand Down
Loading