forked from spoonconsulting/cordova-plugin-background-upload
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Android: Several fixes and improvements to UploadTask.
This is a large commit, necessitated by the wrapping of most of `doWork()` by a large `try`/`catch` block. Which aims to fix several long-standing issues and improve our ability to understand the code and make improvements in hte long term. First, comments were added. Members of my team (myself included) aren't used to looking at this, so we took notes about what goes on in the class to help us better understand what is going on. Second, an outer `try` was added so that we could figure out what exceptions were causing our use cases to fail. It turns out that sometimes the `response` can be null—without throwing an exception! Third, some of the logic of how workers pick up uploads and processed them was updated (and hopefully improved). - This includes a change which marks upload as pending. In our experience, an upload which failed could continue to be loaded as the "next" upload to process, thereby making no future uploads work until the applications cache was removed. We also ran into an issue where sometimes uploads would execute 2 or 3 times, this change ensures that an upload only gets processed one time. In our application, we handle retries ourselves, so this works with our use-case. - Avoid some cases where we would "return" rather than continue. I think a problem we found was that due to errors in how the uploads worked, we would often get a "backlog" of uploads that needed to be sent. These changes may need to be re-thought, but essentially, we allow each worker to continue until there are no more uploads to process. - A few more checks for error conditions were added and messages to reflect that status were added. We now mark all failed as completed so that they will get reaped at the end of the process. - With the additional `try`/`catch` block and checks added, the worker processes are now "cleaning up" the upload table correct when they finish, which, again, hopefully will mean we can simplify this task even more in the future. Methods for emitting errors were added to simplify emitting those messages.
- Loading branch information
Showing
2 changed files
with
149 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters