{"action":"created","comment":{"url":"https://api.github.com/repos/novoda/download-manager/pulls/comments/35304173","id":35304173,"diff_hunk":"@@ -370,9 +371,34 @@ private boolean updateLocked() {\n             alarmManager.set(AlarmManager.RTC_WAKEUP, now + nextRetryTimeMillis, PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_ONE_SHOT));\n         }\n \n+        if (!isActive) {\n+            moveSubmittedTasksToBatchStatusIfNecessary();\n+        }\n+\n         return isActive;\n     }\n \n+    private void moveSubmittedTasksToBatchStatusIfNecessary() {","path":"library/src/main/java/com/novoda/downloadmanager/lib/DownloadService.java","position":19,"original_position":19,"commit_id":"3abb36bdc35974aa34f6810c543d72e71e7f84d3","original_commit_id":"3abb36bdc35974aa34f6810c543d72e71e7f84d3","user":{"login":"amlcurran","id":666285,"avatar_url":"https://avatars.githubusercontent.com/u/666285?v=3","gravatar_id":"","url":"https://api.github.com/users/amlcurran","html_url":"https://github.com/amlcurran","followers_url":"https://api.github.com/users/amlcurran/followers","following_url":"https://api.github.com/users/amlcurran/following{/other_user}","gists_url":"https://api.github.com/users/amlcurran/gists{/gist_id}","starred_url":"https://api.github.com/users/amlcurran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amlcurran/subscriptions","organizations_url":"https://api.github.com/users/amlcurran/orgs","repos_url":"https://api.github.com/users/amlcurran/repos","events_url":"https://api.github.com/users/amlcurran/events{/privacy}","received_events_url":"https://api.github.com/users/amlcurran/received_events","type":"User","site_admin":false},"body":"is there any way we can do this without so many queries?","created_at":"2015-07-23T09:27:25Z","updated_at":"2015-07-23T09:27:25Z","html_url":"https://github.com/novoda/download-manager/pull/128#discussion_r35304173","pull_request_url":"https://api.github.com/repos/novoda/download-manager/pulls/128","_links":{"self":{"href":"https://api.github.com/repos/novoda/download-manager/pulls/comments/35304173"},"html":{"href":"https://github.com/novoda/download-manager/pull/128#discussion_r35304173"},"pull_request":{"href":"https://api.github.com/repos/novoda/download-manager/pulls/128"}}},"pull_request":{"url":"https://api.github.com/repos/novoda/download-manager/pulls/128","id":40590258,"html_url":"https://github.com/novoda/download-manager/pull/128","diff_url":"https://github.com/novoda/download-manager/pull/128.diff","patch_url":"https://github.com/novoda/download-manager/pull/128.patch","issue_url":"https://api.github.com/repos/novoda/download-manager/issues/128","number":128,"state":"open","locked":false,"title":"Resume downloads after loosing signal","user":{"login":"zegnus","id":2845931,"avatar_url":"https://avatars.githubusercontent.com/u/2845931?v=3","gravatar_id":"","url":"https://api.github.com/users/zegnus","html_url":"https://github.com/zegnus","followers_url":"https://api.github.com/users/zegnus/followers","following_url":"https://api.github.com/users/zegnus/following{/other_user}","gists_url":"https://api.github.com/users/zegnus/gists{/gist_id}","starred_url":"https://api.github.com/users/zegnus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zegnus/subscriptions","organizations_url":"https://api.github.com/users/zegnus/orgs","repos_url":"https://api.github.com/users/zegnus/repos","events_url":"https://api.github.com/users/zegnus/events{/privacy}","received_events_url":"https://api.github.com/users/zegnus/received_events","type":"User","site_admin":false},"body":"## Task description ##\r\n\r\nThe current download implementation does not support loosing the signal while processing batches\r\n\r\n## Solution implemented ##\r\n\r\n- When the `DownloadService` is about to be killed, we move all the submitted tasks to the batch status\r\n- When the `DownloadThread`is about to abort due to client checks, we move that task to a new queued status\r\n- Support for resume and TAGs has been added along with a new `Request` flag `applicationChecksFileIntegrity`. Notice that if eTags with resumable downloads is needed, the client must activate the new flag in the request.\r\n\r\nThis covers the following scenarios:\r\n- Wifi drops while downloading, progress and submitted tasks goes into a queued status\r\n- When wifi is recovered, all previous queued downloads continue\r\n- When a download finishes and tries the following one, it is possible that the client check fails. Previously we were going into an unstable status. This is covered now.\r\n- All queued downloads resumes and the batch finishes to download properly","created_at":"2015-07-22T17:29:10Z","updated_at":"2015-07-23T09:27:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"52a0db0e4ba24df92571e3633941c72dcf3c7a87","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/novoda/download-manager/pulls/128/commits","review_comments_url":"https://api.github.com/repos/novoda/download-manager/pulls/128/comments","review_comment_url":"https://api.github.com/repos/novoda/download-manager/pulls/comments{/number}","comments_url":"https://api.github.com/repos/novoda/download-manager/issues/128/comments","statuses_url":"https://api.github.com/repos/novoda/download-manager/statuses/3abb36bdc35974aa34f6810c543d72e71e7f84d3","head":{"label":"novoda:Resume-downloads-after-loosing-signal","ref":"Resume-downloads-after-loosing-signal","sha":"3abb36bdc35974aa34f6810c543d72e71e7f84d3","user":{"login":"novoda","id":74874,"avatar_url":"https://avatars.githubusercontent.com/u/74874?v=3","gravatar_id":"","url":"https://api.github.com/users/novoda","html_url":"https://github.com/novoda","followers_url":"https://api.github.com/users/novoda/followers","following_url":"https://api.github.com/users/novoda/following{/other_user}","gists_url":"https://api.github.com/users/novoda/gists{/gist_id}","starred_url":"https://api.github.com/users/novoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novoda/subscriptions","organizations_url":"https://api.github.com/users/novoda/orgs","repos_url":"https://api.github.com/users/novoda/repos","events_url":"https://api.github.com/users/novoda/events{/privacy}","received_events_url":"https://api.github.com/users/novoda/received_events","type":"Organization","site_admin":false},"repo":{"id":35211795,"name":"download-manager","full_name":"novoda/download-manager","owner":{"login":"novoda","id":74874,"avatar_url":"https://avatars.githubusercontent.com/u/74874?v=3","gravatar_id":"","url":"https://api.github.com/users/novoda","html_url":"https://github.com/novoda","followers_url":"https://api.github.com/users/novoda/followers","following_url":"https://api.github.com/users/novoda/following{/other_user}","gists_url":"https://api.github.com/users/novoda/gists{/gist_id}","starred_url":"https://api.github.com/users/novoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novoda/subscriptions","organizations_url":"https://api.github.com/users/novoda/orgs","repos_url":"https://api.github.com/users/novoda/repos","events_url":"https://api.github.com/users/novoda/events{/privacy}","received_events_url":"https://api.github.com/users/novoda/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/novoda/download-manager","description":"Download manager based on AOSP DM but allowing downloading to internal private storage","fork":false,"url":"https://api.github.com/repos/novoda/download-manager","forks_url":"https://api.github.com/repos/novoda/download-manager/forks","keys_url":"https://api.github.com/repos/novoda/download-manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/novoda/download-manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/novoda/download-manager/teams","hooks_url":"https://api.github.com/repos/novoda/download-manager/hooks","issue_events_url":"https://api.github.com/repos/novoda/download-manager/issues/events{/number}","events_url":"https://api.github.com/repos/novoda/download-manager/events","assignees_url":"https://api.github.com/repos/novoda/download-manager/assignees{/user}","branches_url":"https://api.github.com/repos/novoda/download-manager/branches{/branch}","tags_url":"https://api.github.com/repos/novoda/download-manager/tags","blobs_url":"https://api.github.com/repos/novoda/download-manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/novoda/download-manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/novoda/download-manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/novoda/download-manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/novoda/download-manager/statuses/{sha}","languages_url":"https://api.github.com/repos/novoda/download-manager/languages","stargazers_url":"https://api.github.com/repos/novoda/download-manager/stargazers","contributors_url":"https://api.github.com/repos/novoda/download-manager/contributors","subscribers_url":"https://api.github.com/repos/novoda/download-manager/subscribers","subscription_url":"https://api.github.com/repos/novoda/download-manager/subscription","commits_url":"https://api.github.com/repos/novoda/download-manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/novoda/download-manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/novoda/download-manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/novoda/download-manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/novoda/download-manager/contents/{+path}","compare_url":"https://api.github.com/repos/novoda/download-manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/novoda/download-manager/merges","archive_url":"https://api.github.com/repos/novoda/download-manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/novoda/download-manager/downloads","issues_url":"https://api.github.com/repos/novoda/download-manager/issues{/number}","pulls_url":"https://api.github.com/repos/novoda/download-manager/pulls{/number}","milestones_url":"https://api.github.com/repos/novoda/download-manager/milestones{/number}","notifications_url":"https://api.github.com/repos/novoda/download-manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/novoda/download-manager/labels{/name}","releases_url":"https://api.github.com/repos/novoda/download-manager/releases{/id}","created_at":"2015-05-07T09:41:52Z","updated_at":"2015-07-23T09:24:36Z","pushed_at":"2015-07-23T08:20:36Z","git_url":"git://github.com/novoda/download-manager.git","ssh_url":"git@github.com:novoda/download-manager.git","clone_url":"https://github.com/novoda/download-manager.git","svn_url":"https://github.com/novoda/download-manager","homepage":"","size":4185,"stargazers_count":57,"watchers_count":57,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":20,"forks":5,"open_issues":20,"watchers":57,"default_branch":"master"}},"base":{"label":"novoda:master","ref":"master","sha":"e0ebc82b340a4acd3ac01d06436504710afc8ab7","user":{"login":"novoda","id":74874,"avatar_url":"https://avatars.githubusercontent.com/u/74874?v=3","gravatar_id":"","url":"https://api.github.com/users/novoda","html_url":"https://github.com/novoda","followers_url":"https://api.github.com/users/novoda/followers","following_url":"https://api.github.com/users/novoda/following{/other_user}","gists_url":"https://api.github.com/users/novoda/gists{/gist_id}","starred_url":"https://api.github.com/users/novoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novoda/subscriptions","organizations_url":"https://api.github.com/users/novoda/orgs","repos_url":"https://api.github.com/users/novoda/repos","events_url":"https://api.github.com/users/novoda/events{/privacy}","received_events_url":"https://api.github.com/users/novoda/received_events","type":"Organization","site_admin":false},"repo":{"id":35211795,"name":"download-manager","full_name":"novoda/download-manager","owner":{"login":"novoda","id":74874,"avatar_url":"https://avatars.githubusercontent.com/u/74874?v=3","gravatar_id":"","url":"https://api.github.com/users/novoda","html_url":"https://github.com/novoda","followers_url":"https://api.github.com/users/novoda/followers","following_url":"https://api.github.com/users/novoda/following{/other_user}","gists_url":"https://api.github.com/users/novoda/gists{/gist_id}","starred_url":"https://api.github.com/users/novoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novoda/subscriptions","organizations_url":"https://api.github.com/users/novoda/orgs","repos_url":"https://api.github.com/users/novoda/repos","events_url":"https://api.github.com/users/novoda/events{/privacy}","received_events_url":"https://api.github.com/users/novoda/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/novoda/download-manager","description":"Download manager based on AOSP DM but allowing downloading to internal private storage","fork":false,"url":"https://api.github.com/repos/novoda/download-manager","forks_url":"https://api.github.com/repos/novoda/download-manager/forks","keys_url":"https://api.github.com/repos/novoda/download-manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/novoda/download-manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/novoda/download-manager/teams","hooks_url":"https://api.github.com/repos/novoda/download-manager/hooks","issue_events_url":"https://api.github.com/repos/novoda/download-manager/issues/events{/number}","events_url":"https://api.github.com/repos/novoda/download-manager/events","assignees_url":"https://api.github.com/repos/novoda/download-manager/assignees{/user}","branches_url":"https://api.github.com/repos/novoda/download-manager/branches{/branch}","tags_url":"https://api.github.com/repos/novoda/download-manager/tags","blobs_url":"https://api.github.com/repos/novoda/download-manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/novoda/download-manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/novoda/download-manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/novoda/download-manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/novoda/download-manager/statuses/{sha}","languages_url":"https://api.github.com/repos/novoda/download-manager/languages","stargazers_url":"https://api.github.com/repos/novoda/download-manager/stargazers","contributors_url":"https://api.github.com/repos/novoda/download-manager/contributors","subscribers_url":"https://api.github.com/repos/novoda/download-manager/subscribers","subscription_url":"https://api.github.com/repos/novoda/download-manager/subscription","commits_url":"https://api.github.com/repos/novoda/download-manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/novoda/download-manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/novoda/download-manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/novoda/download-manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/novoda/download-manager/contents/{+path}","compare_url":"https://api.github.com/repos/novoda/download-manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/novoda/download-manager/merges","archive_url":"https://api.github.com/repos/novoda/download-manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/novoda/download-manager/downloads","issues_url":"https://api.github.com/repos/novoda/download-manager/issues{/number}","pulls_url":"https://api.github.com/repos/novoda/download-manager/pulls{/number}","milestones_url":"https://api.github.com/repos/novoda/download-manager/milestones{/number}","notifications_url":"https://api.github.com/repos/novoda/download-manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/novoda/download-manager/labels{/name}","releases_url":"https://api.github.com/repos/novoda/download-manager/releases{/id}","created_at":"2015-05-07T09:41:52Z","updated_at":"2015-07-23T09:24:36Z","pushed_at":"2015-07-23T08:20:36Z","git_url":"git://github.com/novoda/download-manager.git","ssh_url":"git@github.com:novoda/download-manager.git","clone_url":"https://github.com/novoda/download-manager.git","svn_url":"https://github.com/novoda/download-manager","homepage":"","size":4185,"stargazers_count":57,"watchers_count":57,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":20,"forks":5,"open_issues":20,"watchers":57,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/novoda/download-manager/pulls/128"},"html":{"href":"https://github.com/novoda/download-manager/pull/128"},"issue":{"href":"https://api.github.com/repos/novoda/download-manager/issues/128"},"comments":{"href":"https://api.github.com/repos/novoda/download-manager/issues/128/comments"},"review_comments":{"href":"https://api.github.com/repos/novoda/download-manager/pulls/128/comments"},"review_comment":{"href":"https://api.github.com/repos/novoda/download-manager/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/novoda/download-manager/pulls/128/commits"},"statuses":{"href":"https://api.github.com/repos/novoda/download-manager/statuses/3abb36bdc35974aa34f6810c543d72e71e7f84d3"}}}}