GitHub PullRequestReviewCommentEvent at 2014-07-13 11:13:48
Repository: peerlibrary
Actor: mitar
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls/comments/14857880","id":14857880,"diff_hunk":"@@ -74,94 +97,137 @@ uploadFile = (file, publicationId) ->\n           imported: true\n           publicationId: publicationId\n \n-testPDF = (file, fileContent, callback) ->\n-  PDFJS.getDocument(data: fileContent, password: '').then callback, (message, exception) ->\n+# Process next element from import queue\n+Deps.autorun ->\n+  # Autorun will not re-run until the same document does not have finished\n+  # or errored fields set, but after they are set, next file will be returned\n+  document = ImportingFile.documents.findOne\n+    finished: false\n+    errored: false\n+    canceled: false\n+    sha256:\n+      $exists: true\n+  ,\n+    fields:\n+      id: 1\n+      name: 1\n+      sha256: 1\n+  return unless document\n+\n+  ImportingFile.documents.update document._id,\n+    $set:\n+      enqueued: false\n+\n+  Meteor.call 'create-publication', document.name, document.sha256, (error, result) ->\n+    if error\n+      ImportingFile.documents.update document._id,\n+        $set:\n+          errored: true\n+          status: error.toString()\n+      return\n+\n+    if result.already\n+      ImportingFile.documents.update document._id,\n+        $set:\n+          finished: true\n+          status: \"File already imported\"\n+          publicationId: result.publicationId\n+      return\n+\n+    if result.verify\n+      verifyFile importingFiles[document._id], result.publicationId, result.samples\n+    else\n+      uploadFile importingFiles[document._id], result.publicationId\n+\n+computeChecksum = (file, callback) ->\n+  hash = new Crypto.SHA256\n+    onProgress: (progress) ->\n+      ImportingFile.documents.update file._id,\n+      $set:\n+        preprocessingProgress: progress * 100 # %\n+\n+  hash.update file.content, (error) ->\n+    if error\n+      ImportingFile.documents.update file._id,\n+        $set:\n+          errored: true\n+          status: error.toString()\n+      return\n+\n+    hash.finalize callback\n+\n+testPDF = (file, callback) ->\n+  PDFJS.getDocument(data: file.content, password: '').then callback, (message, exception) ->\n     ImportingFile.documents.update file._id,\n       $set:\n         errored: true\n         status: \"Invalid PDF file\"\n \n-importFile = (file) ->\n+# Process next element from preprocessing queue\n+Deps.autorun ->\n+  # Autorun will not re-run until the same document does not yet have\n+  # sha256 field, but after the field is set, next file will be returned\n+  document = ImportingFile.documents.findOne\n+    sha256:\n+      $exists: false\n+    errored: false\n+    finished: false\n+  ,\n+    fields:\n+      _id: 1\n+  return unless document\n+\n+  ImportingFile.documents.update document._id,\n+    $set:\n+      status: \"Preprocessing\"\n+      enqueued: false\n+\n   reader = new FileReader()\n   reader.onload = ->\n-    fileContent = @result\n-\n-    testPDF file, fileContent, ->\n-      hash = new Crypto.SHA256\n-        onProgress: (progress) ->\n-          #TODO: update progressbar\n-      hash.update fileContent, (error, result) ->\n-        #TODO: handle errors\n-        if error\n-          console.log \"Import error: \" + error.message\n-      hash.finalize (error, result) ->\n-        #TODO: handle errors\n+    importingFiles[document._id].content = reader.result\n+    testPDF importingFiles[document._id], ->\n+      computeChecksum importingFiles[document._id], (error, sha256) ->\n         if error\n-          console.log \"Import error: \" + error.message\n-        sha256 = result\n-\n-        alreadyImporting = ImportingFile.documents.findOne(sha256: sha256)\n-        if alreadyImporting\n-          ImportingFile.documents.update file._id,\n+          ImportingFile.documents.update document._id,\n             $set:\n-              finished: true\n-              status: \"File is already importing\"\n-              # publicationId might not yet be available, but let's try\n-              publicationId: alreadyImporting.publicationId\n+              errored: true\n+              status: error.toString()\n           return\n \n-        ImportingFile.documents.update file._id,\n+        ImportingFile.documents.update document._id,\n           $set:\n             sha256: sha256\n+            status: \"In import queue\"\n+            enqueued: true\n+\n+  reader.onerror = (error) ->\n+    console.log \"Error \" + error","path":"client/import.coffee","position":190,"original_position":190,"commit_id":"c155401d19fe7a653a5fa9c28ef768a79731dedb","original_commit_id":"c155401d19fe7a653a5fa9c28ef768a79731dedb","user":{"login":"mitar","id":585279,"avatar_url":"https://avatars.githubusercontent.com/u/585279?","gravatar_id":"e236829c38fb78c4d7f7ff1dd826197e","url":"https://api.github.com/users/mitar","html_url":"https://github.com/mitar","followers_url":"https://api.github.com/users/mitar/followers","following_url":"https://api.github.com/users/mitar/following{/other_user}","gists_url":"https://api.github.com/users/mitar/gists{/gist_id}","starred_url":"https://api.github.com/users/mitar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitar/subscriptions","organizations_url":"https://api.github.com/users/mitar/orgs","repos_url":"https://api.github.com/users/mitar/repos","events_url":"https://api.github.com/users/mitar/events{/privacy}","received_events_url":"https://api.github.com/users/mitar/received_events","type":"User","site_admin":false},"body":"Why you are leaving this in?","created_at":"2014-07-13T11:13:48Z","updated_at":"2014-07-13T11:13:48Z","html_url":"https://github.com/peerlibrary/peerlibrary/pull/510#discussion_r14857880","pull_request_url":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls/510","_links":{"self":{"href":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls/comments/14857880"},"html":{"href":"https://github.com/peerlibrary/peerlibrary/pull/510#discussion_r14857880"},"pull_request":{"href":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls/510"}}},"pull_request":{"url":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls/510","id":16876038,"html_url":"https://github.com/peerlibrary/peerlibrary/pull/510","diff_url":"https://github.com/peerlibrary/peerlibrary/pull/510.diff","patch_url":"https://github.com/peerlibrary/peerlibrary/pull/510.patch","issue_url":"https://api.github.com/repos/peerlibrary/peerlibrary/issues/510","number":510,"state":"open","title":"Multi file upload","user":{"login":"mpranjic","id":2545452,"avatar_url":"https://avatars.githubusercontent.com/u/2545452?","gravatar_id":"3cab24deb680a198e1c051e80be87884","url":"https://api.github.com/users/mpranjic","html_url":"https://github.com/mpranjic","followers_url":"https://api.github.com/users/mpranjic/followers","following_url":"https://api.github.com/users/mpranjic/following{/other_user}","gists_url":"https://api.github.com/users/mpranjic/gists{/gist_id}","starred_url":"https://api.github.com/users/mpranjic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpranjic/subscriptions","organizations_url":"https://api.github.com/users/mpranjic/orgs","repos_url":"https://api.github.com/users/mpranjic/repos","events_url":"https://api.github.com/users/mpranjic/events{/privacy}","received_events_url":"https://api.github.com/users/mpranjic/received_events","type":"User","site_admin":false},"body":"This is a pull request into sha256-custom branch.","created_at":"2014-06-09T08:42:42Z","updated_at":"2014-07-13T11:13:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2d8c673ba587ae94a0c13ff3bfce6695b41288ca","assignee":null,"milestone":{"url":"https://api.github.com/repos/peerlibrary/peerlibrary/milestones/18","labels_url":"https://api.github.com/repos/peerlibrary/peerlibrary/milestones/18/labels","id":646470,"number":18,"title":"0.3 - Waffle","description":"Inviting users to join groups and permissions.\r\nMaking collections top-level entity and making library a default collection.\r\nMake lists of recent activity for publications, highlights, annotations, collections, groups, and allow them to be browsed and searched.\r\n","creator":{"login":"mitar","id":585279,"avatar_url":"https://avatars.githubusercontent.com/u/585279?","gravatar_id":"e236829c38fb78c4d7f7ff1dd826197e","url":"https://api.github.com/users/mitar","html_url":"https://github.com/mitar","followers_url":"https://api.github.com/users/mitar/followers","following_url":"https://api.github.com/users/mitar/following{/other_user}","gists_url":"https://api.github.com/users/mitar/gists{/gist_id}","starred_url":"https://api.github.com/users/mitar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitar/subscriptions","organizations_url":"https://api.github.com/users/mitar/orgs","repos_url":"https://api.github.com/users/mitar/repos","events_url":"https://api.github.com/users/mitar/events{/privacy}","received_events_url":"https://api.github.com/users/mitar/received_events","type":"User","site_admin":false},"open_issues":37,"closed_issues":44,"state":"open","created_at":"2014-05-01T21:24:58Z","updated_at":"2014-07-10T20:09:54Z","due_on":"2014-06-10T07:00:00Z"},"commits_url":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls/510/commits","review_comments_url":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls/510/comments","review_comment_url":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls/comments/{number}","comments_url":"https://api.github.com/repos/peerlibrary/peerlibrary/issues/510/comments","statuses_url":"https://api.github.com/repos/peerlibrary/peerlibrary/statuses/c155401d19fe7a653a5fa9c28ef768a79731dedb","head":{"label":"peerlibrary:multi-file-upload","ref":"multi-file-upload","sha":"c155401d19fe7a653a5fa9c28ef768a79731dedb","user":{"login":"peerlibrary","id":3861814,"avatar_url":"https://avatars.githubusercontent.com/u/3861814?","gravatar_id":"d32ca274844f5ad91365498c43546458","url":"https://api.github.com/users/peerlibrary","html_url":"https://github.com/peerlibrary","followers_url":"https://api.github.com/users/peerlibrary/followers","following_url":"https://api.github.com/users/peerlibrary/following{/other_user}","gists_url":"https://api.github.com/users/peerlibrary/gists{/gist_id}","starred_url":"https://api.github.com/users/peerlibrary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peerlibrary/subscriptions","organizations_url":"https://api.github.com/users/peerlibrary/orgs","repos_url":"https://api.github.com/users/peerlibrary/repos","events_url":"https://api.github.com/users/peerlibrary/events{/privacy}","received_events_url":"https://api.github.com/users/peerlibrary/received_events","type":"Organization","site_admin":false},"repo":{"id":8770296,"name":"peerlibrary","full_name":"peerlibrary/peerlibrary","owner":{"login":"peerlibrary","id":3861814,"avatar_url":"https://avatars.githubusercontent.com/u/3861814?","gravatar_id":"d32ca274844f5ad91365498c43546458","url":"https://api.github.com/users/peerlibrary","html_url":"https://github.com/peerlibrary","followers_url":"https://api.github.com/users/peerlibrary/followers","following_url":"https://api.github.com/users/peerlibrary/following{/other_user}","gists_url":"https://api.github.com/users/peerlibrary/gists{/gist_id}","starred_url":"https://api.github.com/users/peerlibrary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peerlibrary/subscriptions","organizations_url":"https://api.github.com/users/peerlibrary/orgs","repos_url":"https://api.github.com/users/peerlibrary/repos","events_url":"https://api.github.com/users/peerlibrary/events{/privacy}","received_events_url":"https://api.github.com/users/peerlibrary/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/peerlibrary/peerlibrary","description":"Facilitating the global conversation on academic literature","fork":false,"url":"https://api.github.com/repos/peerlibrary/peerlibrary","forks_url":"https://api.github.com/repos/peerlibrary/peerlibrary/forks","keys_url":"https://api.github.com/repos/peerlibrary/peerlibrary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/peerlibrary/peerlibrary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/peerlibrary/peerlibrary/teams","hooks_url":"https://api.github.com/repos/peerlibrary/peerlibrary/hooks","issue_events_url":"https://api.github.com/repos/peerlibrary/peerlibrary/issues/events{/number}","events_url":"https://api.github.com/repos/peerlibrary/peerlibrary/events","assignees_url":"https://api.github.com/repos/peerlibrary/peerlibrary/assignees{/user}","branches_url":"https://api.github.com/repos/peerlibrary/peerlibrary/branches{/branch}","tags_url":"https://api.github.com/repos/peerlibrary/peerlibrary/tags","blobs_url":"https://api.github.com/repos/peerlibrary/peerlibrary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/peerlibrary/peerlibrary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/peerlibrary/peerlibrary/git/refs{/sha}","trees_url":"https://api.github.com/repos/peerlibrary/peerlibrary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/peerlibrary/peerlibrary/statuses/{sha}","languages_url":"https://api.github.com/repos/peerlibrary/peerlibrary/languages","stargazers_url":"https://api.github.com/repos/peerlibrary/peerlibrary/stargazers","contributors_url":"https://api.github.com/repos/peerlibrary/peerlibrary/contributors","subscribers_url":"https://api.github.com/repos/peerlibrary/peerlibrary/subscribers","subscription_url":"https://api.github.com/repos/peerlibrary/peerlibrary/subscription","commits_url":"https://api.github.com/repos/peerlibrary/peerlibrary/commits{/sha}","git_commits_url":"https://api.github.com/repos/peerlibrary/peerlibrary/git/commits{/sha}","comments_url":"https://api.github.com/repos/peerlibrary/peerlibrary/comments{/number}","issue_comment_url":"https://api.github.com/repos/peerlibrary/peerlibrary/issues/comments/{number}","contents_url":"https://api.github.com/repos/peerlibrary/peerlibrary/contents/{+path}","compare_url":"https://api.github.com/repos/peerlibrary/peerlibrary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/peerlibrary/peerlibrary/merges","archive_url":"https://api.github.com/repos/peerlibrary/peerlibrary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/peerlibrary/peerlibrary/downloads","issues_url":"https://api.github.com/repos/peerlibrary/peerlibrary/issues{/number}","pulls_url":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls{/number}","milestones_url":"https://api.github.com/repos/peerlibrary/peerlibrary/milestones{/number}","notifications_url":"https://api.github.com/repos/peerlibrary/peerlibrary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/peerlibrary/peerlibrary/labels{/name}","releases_url":"https://api.github.com/repos/peerlibrary/peerlibrary/releases{/id}","created_at":"2013-03-14T07:26:54Z","updated_at":"2014-07-06T12:35:24Z","pushed_at":"2014-07-13T02:46:03Z","git_url":"git://github.com/peerlibrary/peerlibrary.git","ssh_url":"git@github.com:peerlibrary/peerlibrary.git","clone_url":"https://github.com/peerlibrary/peerlibrary.git","svn_url":"https://github.com/peerlibrary/peerlibrary","homepage":"https://peerlibrary.org/","size":24425,"stargazers_count":100,"watchers_count":100,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":22,"mirror_url":null,"open_issues_count":299,"forks":22,"open_issues":299,"watchers":100,"default_branch":"development"}},"base":{"label":"peerlibrary:sha256-custom","ref":"sha256-custom","sha":"bc24d1a67893d739db88f641a8cffdc9264fa8d8","user":{"login":"peerlibrary","id":3861814,"avatar_url":"https://avatars.githubusercontent.com/u/3861814?","gravatar_id":"d32ca274844f5ad91365498c43546458","url":"https://api.github.com/users/peerlibrary","html_url":"https://github.com/peerlibrary","followers_url":"https://api.github.com/users/peerlibrary/followers","following_url":"https://api.github.com/users/peerlibrary/following{/other_user}","gists_url":"https://api.github.com/users/peerlibrary/gists{/gist_id}","starred_url":"https://api.github.com/users/peerlibrary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peerlibrary/subscriptions","organizations_url":"https://api.github.com/users/peerlibrary/orgs","repos_url":"https://api.github.com/users/peerlibrary/repos","events_url":"https://api.github.com/users/peerlibrary/events{/privacy}","received_events_url":"https://api.github.com/users/peerlibrary/received_events","type":"Organization","site_admin":false},"repo":{"id":8770296,"name":"peerlibrary","full_name":"peerlibrary/peerlibrary","owner":{"login":"peerlibrary","id":3861814,"avatar_url":"https://avatars.githubusercontent.com/u/3861814?","gravatar_id":"d32ca274844f5ad91365498c43546458","url":"https://api.github.com/users/peerlibrary","html_url":"https://github.com/peerlibrary","followers_url":"https://api.github.com/users/peerlibrary/followers","following_url":"https://api.github.com/users/peerlibrary/following{/other_user}","gists_url":"https://api.github.com/users/peerlibrary/gists{/gist_id}","starred_url":"https://api.github.com/users/peerlibrary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peerlibrary/subscriptions","organizations_url":"https://api.github.com/users/peerlibrary/orgs","repos_url":"https://api.github.com/users/peerlibrary/repos","events_url":"https://api.github.com/users/peerlibrary/events{/privacy}","received_events_url":"https://api.github.com/users/peerlibrary/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/peerlibrary/peerlibrary","description":"Facilitating the global conversation on academic literature","fork":false,"url":"https://api.github.com/repos/peerlibrary/peerlibrary","forks_url":"https://api.github.com/repos/peerlibrary/peerlibrary/forks","keys_url":"https://api.github.com/repos/peerlibrary/peerlibrary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/peerlibrary/peerlibrary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/peerlibrary/peerlibrary/teams","hooks_url":"https://api.github.com/repos/peerlibrary/peerlibrary/hooks","issue_events_url":"https://api.github.com/repos/peerlibrary/peerlibrary/issues/events{/number}","events_url":"https://api.github.com/repos/peerlibrary/peerlibrary/events","assignees_url":"https://api.github.com/repos/peerlibrary/peerlibrary/assignees{/user}","branches_url":"https://api.github.com/repos/peerlibrary/peerlibrary/branches{/branch}","tags_url":"https://api.github.com/repos/peerlibrary/peerlibrary/tags","blobs_url":"https://api.github.com/repos/peerlibrary/peerlibrary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/peerlibrary/peerlibrary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/peerlibrary/peerlibrary/git/refs{/sha}","trees_url":"https://api.github.com/repos/peerlibrary/peerlibrary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/peerlibrary/peerlibrary/statuses/{sha}","languages_url":"https://api.github.com/repos/peerlibrary/peerlibrary/languages","stargazers_url":"https://api.github.com/repos/peerlibrary/peerlibrary/stargazers","contributors_url":"https://api.github.com/repos/peerlibrary/peerlibrary/contributors","subscribers_url":"https://api.github.com/repos/peerlibrary/peerlibrary/subscribers","subscription_url":"https://api.github.com/repos/peerlibrary/peerlibrary/subscription","commits_url":"https://api.github.com/repos/peerlibrary/peerlibrary/commits{/sha}","git_commits_url":"https://api.github.com/repos/peerlibrary/peerlibrary/git/commits{/sha}","comments_url":"https://api.github.com/repos/peerlibrary/peerlibrary/comments{/number}","issue_comment_url":"https://api.github.com/repos/peerlibrary/peerlibrary/issues/comments/{number}","contents_url":"https://api.github.com/repos/peerlibrary/peerlibrary/contents/{+path}","compare_url":"https://api.github.com/repos/peerlibrary/peerlibrary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/peerlibrary/peerlibrary/merges","archive_url":"https://api.github.com/repos/peerlibrary/peerlibrary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/peerlibrary/peerlibrary/downloads","issues_url":"https://api.github.com/repos/peerlibrary/peerlibrary/issues{/number}","pulls_url":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls{/number}","milestones_url":"https://api.github.com/repos/peerlibrary/peerlibrary/milestones{/number}","notifications_url":"https://api.github.com/repos/peerlibrary/peerlibrary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/peerlibrary/peerlibrary/labels{/name}","releases_url":"https://api.github.com/repos/peerlibrary/peerlibrary/releases{/id}","created_at":"2013-03-14T07:26:54Z","updated_at":"2014-07-06T12:35:24Z","pushed_at":"2014-07-13T02:46:03Z","git_url":"git://github.com/peerlibrary/peerlibrary.git","ssh_url":"git@github.com:peerlibrary/peerlibrary.git","clone_url":"https://github.com/peerlibrary/peerlibrary.git","svn_url":"https://github.com/peerlibrary/peerlibrary","homepage":"https://peerlibrary.org/","size":24425,"stargazers_count":100,"watchers_count":100,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":22,"mirror_url":null,"open_issues_count":299,"forks":22,"open_issues":299,"watchers":100,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls/510"},"html":{"href":"https://github.com/peerlibrary/peerlibrary/pull/510"},"issue":{"href":"https://api.github.com/repos/peerlibrary/peerlibrary/issues/510"},"comments":{"href":"https://api.github.com/repos/peerlibrary/peerlibrary/issues/510/comments"},"review_comments":{"href":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls/510/comments"},"review_comment":{"href":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/peerlibrary/peerlibrary/pulls/510/commits"},"statuses":{"href":"https://api.github.com/repos/peerlibrary/peerlibrary/statuses/c155401d19fe7a653a5fa9c28ef768a79731dedb"}}}}