{"action":"created","comment":{"url":"https://api.github.com/repos/WhisperSystems/TextSecure/pulls/comments/22756133","id":22756133,"diff_hunk":"@@ -452,6 +550,31 @@ public void updatePartThumbnail(MasterSecret masterSecret, long partId, PduPart\n     values.put(THUMBNAIL, thumbnailFile.first.getAbsolutePath());\n     values.put(ASPECT_RATIO, aspectRatio);\n \n-    database.update(TABLE_NAME, values, ID_WHERE, new String[] {partId + \"\"});\n+    database.update(TABLE_NAME, values, ID_WHERE, new String[]{partId+\"\"});\n+  }\n+\n+  public void markThumbnailTaskStarted(long partId) {\n+    synchronized (thumbnailTasks) {\n+      thumbnailTasks.add(partId);\n+    }\n+  }\n+\n+  public boolean markThumbnailTaskStartedIfAbsent(long partId) throws FileNotFoundException {","path":"src/org/thoughtcrime/securesms/database/PartDatabase.java","position":259,"original_position":259,"commit_id":"17f90aebc38fc9ae4daa17451900dcc49edfce22","original_commit_id":"17f90aebc38fc9ae4daa17451900dcc49edfce22","user":{"login":"moxie0","id":512439,"avatar_url":"https://avatars.githubusercontent.com/u/512439?v=3","gravatar_id":"","url":"https://api.github.com/users/moxie0","html_url":"https://github.com/moxie0","followers_url":"https://api.github.com/users/moxie0/followers","following_url":"https://api.github.com/users/moxie0/following{/other_user}","gists_url":"https://api.github.com/users/moxie0/gists{/gist_id}","starred_url":"https://api.github.com/users/moxie0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moxie0/subscriptions","organizations_url":"https://api.github.com/users/moxie0/orgs","repos_url":"https://api.github.com/users/moxie0/repos","events_url":"https://api.github.com/users/moxie0/events{/privacy}","received_events_url":"https://api.github.com/users/moxie0/received_events","type":"User","site_admin":false},"body":"I don't think you need to double-check here if you're only calling it from the Job, but I think it'd actually be better if you rewrote this to use it in both places.  Have this return an InputStream if it's present, or null *and acquire the lock* if it's not.  Then get rid of isThumbnailInDatabase all together, and refactor the getThumbnailStream to use this method and be super-short.","created_at":"2015-01-10T04:01:02Z","updated_at":"2015-01-10T04:01:02Z","html_url":"https://github.com/WhisperSystems/TextSecure/pull/2286#discussion_r22756133","pull_request_url":"https://api.github.com/repos/WhisperSystems/TextSecure/pulls/2286","_links":{"self":{"href":"https://api.github.com/repos/WhisperSystems/TextSecure/pulls/comments/22756133"},"html":{"href":"https://github.com/WhisperSystems/TextSecure/pull/2286#discussion_r22756133"},"pull_request":{"href":"https://api.github.com/repos/WhisperSystems/TextSecure/pulls/2286"}}},"pull_request":{"url":"https://api.github.com/repos/WhisperSystems/TextSecure/pulls/2286","id":26739950,"html_url":"https://github.com/WhisperSystems/TextSecure/pull/2286","diff_url":"https://github.com/WhisperSystems/TextSecure/pull/2286.diff","patch_url":"https://github.com/WhisperSystems/TextSecure/pull/2286.patch","issue_url":"https://api.github.com/repos/WhisperSystems/TextSecure/issues/2286","number":2286,"state":"open","locked":false,"title":"use PartDatabase to look up thumbnails async","user":{"login":"mcginty","id":373823,"avatar_url":"https://avatars.githubusercontent.com/u/373823?v=3","gravatar_id":"","url":"https://api.github.com/users/mcginty","html_url":"https://github.com/mcginty","followers_url":"https://api.github.com/users/mcginty/followers","following_url":"https://api.github.com/users/mcginty/following{/other_user}","gists_url":"https://api.github.com/users/mcginty/gists{/gist_id}","starred_url":"https://api.github.com/users/mcginty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcginty/subscriptions","organizations_url":"https://api.github.com/users/mcginty/orgs","repos_url":"https://api.github.com/users/mcginty/repos","events_url":"https://api.github.com/users/mcginty/events{/privacy}","received_events_url":"https://api.github.com/users/mcginty/received_events","type":"User","site_admin":false},"body":"Prevent excessive resource contention from generating two thumbnails for the same piece of media when sending/receiving into an open conversation.","created_at":"2015-01-01T02:10:49Z","updated_at":"2015-01-10T04:01:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"19604e7449c817c26f05aeea0310e6ef7d5c7ed9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/WhisperSystems/TextSecure/pulls/2286/commits","review_comments_url":"https://api.github.com/repos/WhisperSystems/TextSecure/pulls/2286/comments","review_comment_url":"https://api.github.com/repos/WhisperSystems/TextSecure/pulls/comments/{number}","comments_url":"https://api.github.com/repos/WhisperSystems/TextSecure/issues/2286/comments","statuses_url":"https://api.github.com/repos/WhisperSystems/TextSecure/statuses/17f90aebc38fc9ae4daa17451900dcc49edfce22","head":{"label":"mcginty:thumbnail-job-mgmt","ref":"thumbnail-job-mgmt","sha":"17f90aebc38fc9ae4daa17451900dcc49edfce22","user":{"login":"mcginty","id":373823,"avatar_url":"https://avatars.githubusercontent.com/u/373823?v=3","gravatar_id":"","url":"https://api.github.com/users/mcginty","html_url":"https://github.com/mcginty","followers_url":"https://api.github.com/users/mcginty/followers","following_url":"https://api.github.com/users/mcginty/following{/other_user}","gists_url":"https://api.github.com/users/mcginty/gists{/gist_id}","starred_url":"https://api.github.com/users/mcginty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcginty/subscriptions","organizations_url":"https://api.github.com/users/mcginty/orgs","repos_url":"https://api.github.com/users/mcginty/repos","events_url":"https://api.github.com/users/mcginty/events{/privacy}","received_events_url":"https://api.github.com/users/mcginty/received_events","type":"User","site_admin":false},"repo":{"id":15718405,"name":"TextSecure","full_name":"mcginty/TextSecure","owner":{"login":"mcginty","id":373823,"avatar_url":"https://avatars.githubusercontent.com/u/373823?v=3","gravatar_id":"","url":"https://api.github.com/users/mcginty","html_url":"https://github.com/mcginty","followers_url":"https://api.github.com/users/mcginty/followers","following_url":"https://api.github.com/users/mcginty/following{/other_user}","gists_url":"https://api.github.com/users/mcginty/gists{/gist_id}","starred_url":"https://api.github.com/users/mcginty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcginty/subscriptions","organizations_url":"https://api.github.com/users/mcginty/orgs","repos_url":"https://api.github.com/users/mcginty/repos","events_url":"https://api.github.com/users/mcginty/events{/privacy}","received_events_url":"https://api.github.com/users/mcginty/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mcginty/TextSecure","description":"A secure text messaging application for Android.","fork":true,"url":"https://api.github.com/repos/mcginty/TextSecure","forks_url":"https://api.github.com/repos/mcginty/TextSecure/forks","keys_url":"https://api.github.com/repos/mcginty/TextSecure/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mcginty/TextSecure/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mcginty/TextSecure/teams","hooks_url":"https://api.github.com/repos/mcginty/TextSecure/hooks","issue_events_url":"https://api.github.com/repos/mcginty/TextSecure/issues/events{/number}","events_url":"https://api.github.com/repos/mcginty/TextSecure/events","assignees_url":"https://api.github.com/repos/mcginty/TextSecure/assignees{/user}","branches_url":"https://api.github.com/repos/mcginty/TextSecure/branches{/branch}","tags_url":"https://api.github.com/repos/mcginty/TextSecure/tags","blobs_url":"https://api.github.com/repos/mcginty/TextSecure/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mcginty/TextSecure/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mcginty/TextSecure/git/refs{/sha}","trees_url":"https://api.github.com/repos/mcginty/TextSecure/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mcginty/TextSecure/statuses/{sha}","languages_url":"https://api.github.com/repos/mcginty/TextSecure/languages","stargazers_url":"https://api.github.com/repos/mcginty/TextSecure/stargazers","contributors_url":"https://api.github.com/repos/mcginty/TextSecure/contributors","subscribers_url":"https://api.github.com/repos/mcginty/TextSecure/subscribers","subscription_url":"https://api.github.com/repos/mcginty/TextSecure/subscription","commits_url":"https://api.github.com/repos/mcginty/TextSecure/commits{/sha}","git_commits_url":"https://api.github.com/repos/mcginty/TextSecure/git/commits{/sha}","comments_url":"https://api.github.com/repos/mcginty/TextSecure/comments{/number}","issue_comment_url":"https://api.github.com/repos/mcginty/TextSecure/issues/comments/{number}","contents_url":"https://api.github.com/repos/mcginty/TextSecure/contents/{+path}","compare_url":"https://api.github.com/repos/mcginty/TextSecure/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mcginty/TextSecure/merges","archive_url":"https://api.github.com/repos/mcginty/TextSecure/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mcginty/TextSecure/downloads","issues_url":"https://api.github.com/repos/mcginty/TextSecure/issues{/number}","pulls_url":"https://api.github.com/repos/mcginty/TextSecure/pulls{/number}","milestones_url":"https://api.github.com/repos/mcginty/TextSecure/milestones{/number}","notifications_url":"https://api.github.com/repos/mcginty/TextSecure/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mcginty/TextSecure/labels{/name}","releases_url":"https://api.github.com/repos/mcginty/TextSecure/releases{/id}","created_at":"2014-01-07T22:20:58Z","updated_at":"2014-07-16T00:35:32Z","pushed_at":"2015-01-09T04:48:33Z","git_url":"git://github.com/mcginty/TextSecure.git","ssh_url":"git@github.com:mcginty/TextSecure.git","clone_url":"https://github.com/mcginty/TextSecure.git","svn_url":"https://github.com/mcginty/TextSecure","homepage":"","size":47920,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"WhisperSystems:master","ref":"master","sha":"9fed60628d33fb4666759ce0ea030b4a4839326c","user":{"login":"WhisperSystems","id":702459,"avatar_url":"https://avatars.githubusercontent.com/u/702459?v=3","gravatar_id":"","url":"https://api.github.com/users/WhisperSystems","html_url":"https://github.com/WhisperSystems","followers_url":"https://api.github.com/users/WhisperSystems/followers","following_url":"https://api.github.com/users/WhisperSystems/following{/other_user}","gists_url":"https://api.github.com/users/WhisperSystems/gists{/gist_id}","starred_url":"https://api.github.com/users/WhisperSystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WhisperSystems/subscriptions","organizations_url":"https://api.github.com/users/WhisperSystems/orgs","repos_url":"https://api.github.com/users/WhisperSystems/repos","events_url":"https://api.github.com/users/WhisperSystems/events{/privacy}","received_events_url":"https://api.github.com/users/WhisperSystems/received_events","type":"Organization","site_admin":false},"repo":{"id":2990192,"name":"TextSecure","full_name":"WhisperSystems/TextSecure","owner":{"login":"WhisperSystems","id":702459,"avatar_url":"https://avatars.githubusercontent.com/u/702459?v=3","gravatar_id":"","url":"https://api.github.com/users/WhisperSystems","html_url":"https://github.com/WhisperSystems","followers_url":"https://api.github.com/users/WhisperSystems/followers","following_url":"https://api.github.com/users/WhisperSystems/following{/other_user}","gists_url":"https://api.github.com/users/WhisperSystems/gists{/gist_id}","starred_url":"https://api.github.com/users/WhisperSystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WhisperSystems/subscriptions","organizations_url":"https://api.github.com/users/WhisperSystems/orgs","repos_url":"https://api.github.com/users/WhisperSystems/repos","events_url":"https://api.github.com/users/WhisperSystems/events{/privacy}","received_events_url":"https://api.github.com/users/WhisperSystems/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WhisperSystems/TextSecure","description":"A secure text messaging application for Android.","fork":false,"url":"https://api.github.com/repos/WhisperSystems/TextSecure","forks_url":"https://api.github.com/repos/WhisperSystems/TextSecure/forks","keys_url":"https://api.github.com/repos/WhisperSystems/TextSecure/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WhisperSystems/TextSecure/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WhisperSystems/TextSecure/teams","hooks_url":"https://api.github.com/repos/WhisperSystems/TextSecure/hooks","issue_events_url":"https://api.github.com/repos/WhisperSystems/TextSecure/issues/events{/number}","events_url":"https://api.github.com/repos/WhisperSystems/TextSecure/events","assignees_url":"https://api.github.com/repos/WhisperSystems/TextSecure/assignees{/user}","branches_url":"https://api.github.com/repos/WhisperSystems/TextSecure/branches{/branch}","tags_url":"https://api.github.com/repos/WhisperSystems/TextSecure/tags","blobs_url":"https://api.github.com/repos/WhisperSystems/TextSecure/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WhisperSystems/TextSecure/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WhisperSystems/TextSecure/git/refs{/sha}","trees_url":"https://api.github.com/repos/WhisperSystems/TextSecure/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WhisperSystems/TextSecure/statuses/{sha}","languages_url":"https://api.github.com/repos/WhisperSystems/TextSecure/languages","stargazers_url":"https://api.github.com/repos/WhisperSystems/TextSecure/stargazers","contributors_url":"https://api.github.com/repos/WhisperSystems/TextSecure/contributors","subscribers_url":"https://api.github.com/repos/WhisperSystems/TextSecure/subscribers","subscription_url":"https://api.github.com/repos/WhisperSystems/TextSecure/subscription","commits_url":"https://api.github.com/repos/WhisperSystems/TextSecure/commits{/sha}","git_commits_url":"https://api.github.com/repos/WhisperSystems/TextSecure/git/commits{/sha}","comments_url":"https://api.github.com/repos/WhisperSystems/TextSecure/comments{/number}","issue_comment_url":"https://api.github.com/repos/WhisperSystems/TextSecure/issues/comments/{number}","contents_url":"https://api.github.com/repos/WhisperSystems/TextSecure/contents/{+path}","compare_url":"https://api.github.com/repos/WhisperSystems/TextSecure/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WhisperSystems/TextSecure/merges","archive_url":"https://api.github.com/repos/WhisperSystems/TextSecure/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WhisperSystems/TextSecure/downloads","issues_url":"https://api.github.com/repos/WhisperSystems/TextSecure/issues{/number}","pulls_url":"https://api.github.com/repos/WhisperSystems/TextSecure/pulls{/number}","milestones_url":"https://api.github.com/repos/WhisperSystems/TextSecure/milestones{/number}","notifications_url":"https://api.github.com/repos/WhisperSystems/TextSecure/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WhisperSystems/TextSecure/labels{/name}","releases_url":"https://api.github.com/repos/WhisperSystems/TextSecure/releases{/id}","created_at":"2011-12-15T20:01:12Z","updated_at":"2015-01-09T22:41:06Z","pushed_at":"2015-01-09T03:21:21Z","git_url":"git://github.com/WhisperSystems/TextSecure.git","ssh_url":"git@github.com:WhisperSystems/TextSecure.git","clone_url":"https://github.com/WhisperSystems/TextSecure.git","svn_url":"https://github.com/WhisperSystems/TextSecure","homepage":"","size":55565,"stargazers_count":3289,"watchers_count":3289,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":967,"mirror_url":null,"open_issues_count":479,"forks":967,"open_issues":479,"watchers":3289,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/WhisperSystems/TextSecure/pulls/2286"},"html":{"href":"https://github.com/WhisperSystems/TextSecure/pull/2286"},"issue":{"href":"https://api.github.com/repos/WhisperSystems/TextSecure/issues/2286"},"comments":{"href":"https://api.github.com/repos/WhisperSystems/TextSecure/issues/2286/comments"},"review_comments":{"href":"https://api.github.com/repos/WhisperSystems/TextSecure/pulls/2286/comments"},"review_comment":{"href":"https://api.github.com/repos/WhisperSystems/TextSecure/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/WhisperSystems/TextSecure/pulls/2286/commits"},"statuses":{"href":"https://api.github.com/repos/WhisperSystems/TextSecure/statuses/17f90aebc38fc9ae4daa17451900dcc49edfce22"}}}}