GitHub PullRequestReviewCommentEvent at 2014-07-10 19:47:03
Repository: makedrive
Actor: gideonthomas
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/makedrive/pulls/comments/14788409","id":14788409,"diff_hunk":"@@ -343,106 +337,127 @@ rsync.checksums = function(fs, destPath, srcList, options, callback) {\n     return callback(paramError);\n   }\n \n-  configureOptions.call(options);\n-  var result = [];\n+  options = configureOptions(options);\n \n-  function getDirChecksums(entry, callback) {\n-    var item = { path: entry.path, node: entry.node };\n-    var dirPath = getDirPath(destPath, entry.path);\n-    var absPath = Path.join(dirPath, entry.path);\n+  var nodeChecksums = [];\n \n-    if(options.recursive && entry.type === 'DIRECTORY') {\n-      var path = Path.join(destPath, entry.path);\n-      // Create the directory if it does not exist\n-      fs.mkdir(path, function(err) {\n-        if(err && err.code !== 'EEXIST') {\n-          return callback(err);\n+  function checksumsForDir(nodeChecksum, dirPath, absPath, entry, callback) {\n+    var path = Path.join(destPath, entry.path);\n+\n+    // Create the directory if it does not exist\n+    fs.mkdir(path, function(err) {\n+      if(err && err.code !== 'EEXIST') {\n+        return callback(err);\n+      }\n+\n+      rsync.checksums(fs, path, entry.contents, options, function(error, items) {\n+        if(error) {\n+          return callback(error);\n         }\n-        rsync.checksums(fs, path, entry.contents, options, function(error, items) {\n-          if(error) {\n-            return callback(error);\n-          }\n-          // for empty directories where items is undefined\n-          item.contents = items || [];\n-          result.push(item);\n-          callback();\n-        });\n+\n+        // For empty directories where items is undefined\n+        nodeChecksum.contents = items || [];\n+\n+        nodeChecksums.push(nodeChecksum);\n+        callback();\n       });\n-    } else if(entry.type === 'FILE' || !options.links) {\n-      // Make parent directories that do not exist\n-      fs.mkdir(dirPath, function(err) {\n-        if(err && err.code !== 'EEXIST') {\n-          return callback(err);\n-        }\n-        if(!options.checksum || options.recursive) {\n-          fs.stat(absPath, function(err, stat) {\n-            if(!err && stat.mtime === entry.modified && stat.size === entry.size) {\n-              item.checksums = [];\n-              item.modified = entry.modified;\n-              // Indicates that the item is identical to the item in the source\n-              item.identical = true;\n-              result.push(item);\n-              callback();\n-            }\n-            else {\n-              checksum.call(fs, absPath, options, function(err, checksums) {\n-                if(err) {\n-                  return callback(err);\n-                }\n-                item.checksums = checksums;\n-                item.modified = entry.modified;\n-                result.push(item);\n-                callback();\n-              });\n-            }\n-          });\n-        } else {\n-          checksum.call(fs, absPath, options, function(err, checksums) {\n-            if(err) {\n-              return callback(err);\n-            }\n-            item.checksums = checksums;\n-            item.modified = entry.modified;\n-            result.push(item);\n+    });\n+  }\n+\n+  function checksumsForFile(nodeChecksum, dirPath, absPath, entry, callback) {\n+    // Create any parent directories that do not exist\n+    fs.mkdir(dirPath, function(err) {\n+      if(err && err.code !== 'EEXIST') {\n+        return callback(err);\n+      }\n+\n+      if(!options.checksum || options.recursive) {\n+        fs.stat(absPath, function(err, stat) {\n+          if(!err && stat.mtime === entry.modified && stat.size === entry.size) {\n+            nodeChecksum.checksums = [];\n+            nodeChecksum.modified = entry.modified;\n+            // Indicates that the item is identical to the item in the source\n+            nodeChecksum.identical = true;\n+\n+            nodeChecksums.push(nodeChecksum);\n             callback();\n-          });\n-        }\n-      });\n-    }\n-    else if(entry.type === 'SYMLINK'){\n-      // Make parent directories that do not exist\n-      fs.mkdir(dirPath, function(err) {\n-        if(err && err.code !== 'EEXIST') {\n-          return callback(err);\n-        }\n-        if(!options.checksum || options.recursive) {\n-          fs.stat(absPath, function(err, stat){\n-            if(!err && stat.mtime === entry.modified && stat.size === entry.size) {\n-              item.link = true;\n-              result.push(item);\n-              callback();\n-            }\n-            else {\n-              item.link = true;\n-              result.push(item);\n+          } else {\n+            checksum.call(fs, absPath, options, function(err, checksums) {\n+              if(err) {\n+                return callback(err);\n+              }\n+\n+              nodeChecksum.checksums = checksums;\n+              nodeChecksum.modified = entry.modified;\n+\n+              nodeChecksums.push(nodeChecksum);\n               callback();\n-            }\n-          });\n-        } else {\n-          item.link = true;\n-          result.push(item);\n+            });\n+          }\n+        });\n+      } else {\n+        checksum.call(fs, absPath, options, function(err, checksums) {\n+          if(err) {\n+            return callback(err);\n+          }\n+\n+          nodeChecksum.checksums = checksums;\n+          nodeChecksum.modified = entry.modified;\n+\n+          nodeChecksums.push(nodeChecksum);\n           callback();\n-        }\n-      });\n+        });\n+      }\n+    });\n+  }\n+\n+  function checksumsForLink(nodeChecksum, dirPath, absPath, entry, callback) {\n+    // Create any parent directories that do not exist\n+    fs.mkdir(dirPath, function(err) {\n+      if(err && err.code !== 'EEXIST') {\n+        return callback(err);\n+      }\n+\n+      nodeChecksum.link = true;\n+\n+      if(!options.checksum || options.recursive) {\n+        fs.stat(absPath, function(err, stat){\n+          if(!err && stat.mtime === entry.modified && stat.size === entry.size) {\n+            nodeChecksum.identical = true;\n+          }\n+\n+          nodeChecksums.push(nodeChecksum);\n+          callback();\n+        });\n+      } else {\n+        nodeChecksums.push(nodeChecksum);\n+        callback();\n+      }\n+    });\n+  }\n+\n+  function getDirChecksums(entry, callback) {","path":"lib/rsync.js","position":415,"original_position":415,"commit_id":"16c4274a73917a8cd2aa50a3eab9143f1c60b16c","original_commit_id":"16c4274a73917a8cd2aa50a3eab9143f1c60b16c","user":{"login":"gideonthomas","id":5816130,"avatar_url":"https://avatars.githubusercontent.com/u/5816130?","gravatar_id":"b258eac8f9bbbd1cc58948ed37ef4f55","url":"https://api.github.com/users/gideonthomas","html_url":"https://github.com/gideonthomas","followers_url":"https://api.github.com/users/gideonthomas/followers","following_url":"https://api.github.com/users/gideonthomas/following{/other_user}","gists_url":"https://api.github.com/users/gideonthomas/gists{/gist_id}","starred_url":"https://api.github.com/users/gideonthomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gideonthomas/subscriptions","organizations_url":"https://api.github.com/users/gideonthomas/orgs","repos_url":"https://api.github.com/users/gideonthomas/repos","events_url":"https://api.github.com/users/gideonthomas/events{/privacy}","received_events_url":"https://api.github.com/users/gideonthomas/received_events","type":"User","site_admin":false},"body":"node instead of entry","created_at":"2014-07-10T19:47:03Z","updated_at":"2014-07-10T19:47:03Z","html_url":"https://github.com/mozilla/makedrive/pull/64#discussion_r14788409","pull_request_url":"https://api.github.com/repos/mozilla/makedrive/pulls/64","_links":{"self":{"href":"https://api.github.com/repos/mozilla/makedrive/pulls/comments/14788409"},"html":{"href":"https://github.com/mozilla/makedrive/pull/64#discussion_r14788409"},"pull_request":{"href":"https://api.github.com/repos/mozilla/makedrive/pulls/64"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/makedrive/pulls/64","id":18231211,"html_url":"https://github.com/mozilla/makedrive/pull/64","diff_url":"https://github.com/mozilla/makedrive/pull/64.diff","patch_url":"https://github.com/mozilla/makedrive/pull/64.patch","issue_url":"https://api.github.com/repos/mozilla/makedrive/issues/64","number":64,"state":"open","title":"Fix #53 - Refactor rsync","user":{"login":"humphd","id":427398,"avatar_url":"https://avatars.githubusercontent.com/u/427398?","gravatar_id":"467b6f36e2a9ba3f0ec119eddaab6a62","url":"https://api.github.com/users/humphd","html_url":"https://github.com/humphd","followers_url":"https://api.github.com/users/humphd/followers","following_url":"https://api.github.com/users/humphd/following{/other_user}","gists_url":"https://api.github.com/users/humphd/gists{/gist_id}","starred_url":"https://api.github.com/users/humphd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/humphd/subscriptions","organizations_url":"https://api.github.com/users/humphd/orgs","repos_url":"https://api.github.com/users/humphd/repos","events_url":"https://api.github.com/users/humphd/events{/privacy}","received_events_url":"https://api.github.com/users/humphd/received_events","type":"User","site_admin":false},"body":"This is mostly a style cleanup, but I also was able to simplify a number of code paths, eliminate duplicate code, and fix a few bugs. I've also renamed a bunch of variables to make it more clear what's happening, broken things into smaller functions, and re-ordered some operations so the nesting isn't so deep.","created_at":"2014-07-10T16:42:42Z","updated_at":"2014-07-10T19:47:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0064ba063264d05bba2153a0781498125e7c58ca","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/makedrive/pulls/64/commits","review_comments_url":"https://api.github.com/repos/mozilla/makedrive/pulls/64/comments","review_comment_url":"https://api.github.com/repos/mozilla/makedrive/pulls/comments/{number}","comments_url":"https://api.github.com/repos/mozilla/makedrive/issues/64/comments","statuses_url":"https://api.github.com/repos/mozilla/makedrive/statuses/16c4274a73917a8cd2aa50a3eab9143f1c60b16c","head":{"label":"humphd:issue53","ref":"issue53","sha":"16c4274a73917a8cd2aa50a3eab9143f1c60b16c","user":{"login":"humphd","id":427398,"avatar_url":"https://avatars.githubusercontent.com/u/427398?","gravatar_id":"467b6f36e2a9ba3f0ec119eddaab6a62","url":"https://api.github.com/users/humphd","html_url":"https://github.com/humphd","followers_url":"https://api.github.com/users/humphd/followers","following_url":"https://api.github.com/users/humphd/following{/other_user}","gists_url":"https://api.github.com/users/humphd/gists{/gist_id}","starred_url":"https://api.github.com/users/humphd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/humphd/subscriptions","organizations_url":"https://api.github.com/users/humphd/orgs","repos_url":"https://api.github.com/users/humphd/repos","events_url":"https://api.github.com/users/humphd/events{/privacy}","received_events_url":"https://api.github.com/users/humphd/received_events","type":"User","site_admin":false},"repo":{"id":18801855,"name":"makedrive","full_name":"humphd/makedrive","owner":{"login":"humphd","id":427398,"avatar_url":"https://avatars.githubusercontent.com/u/427398?","gravatar_id":"467b6f36e2a9ba3f0ec119eddaab6a62","url":"https://api.github.com/users/humphd","html_url":"https://github.com/humphd","followers_url":"https://api.github.com/users/humphd/followers","following_url":"https://api.github.com/users/humphd/following{/other_user}","gists_url":"https://api.github.com/users/humphd/gists{/gist_id}","starred_url":"https://api.github.com/users/humphd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/humphd/subscriptions","organizations_url":"https://api.github.com/users/humphd/orgs","repos_url":"https://api.github.com/users/humphd/repos","events_url":"https://api.github.com/users/humphd/events{/privacy}","received_events_url":"https://api.github.com/users/humphd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/humphd/makedrive","description":"Webmaker Filesystem","fork":true,"url":"https://api.github.com/repos/humphd/makedrive","forks_url":"https://api.github.com/repos/humphd/makedrive/forks","keys_url":"https://api.github.com/repos/humphd/makedrive/keys{/key_id}","collaborators_url":"https://api.github.com/repos/humphd/makedrive/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/humphd/makedrive/teams","hooks_url":"https://api.github.com/repos/humphd/makedrive/hooks","issue_events_url":"https://api.github.com/repos/humphd/makedrive/issues/events{/number}","events_url":"https://api.github.com/repos/humphd/makedrive/events","assignees_url":"https://api.github.com/repos/humphd/makedrive/assignees{/user}","branches_url":"https://api.github.com/repos/humphd/makedrive/branches{/branch}","tags_url":"https://api.github.com/repos/humphd/makedrive/tags","blobs_url":"https://api.github.com/repos/humphd/makedrive/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/humphd/makedrive/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/humphd/makedrive/git/refs{/sha}","trees_url":"https://api.github.com/repos/humphd/makedrive/git/trees{/sha}","statuses_url":"https://api.github.com/repos/humphd/makedrive/statuses/{sha}","languages_url":"https://api.github.com/repos/humphd/makedrive/languages","stargazers_url":"https://api.github.com/repos/humphd/makedrive/stargazers","contributors_url":"https://api.github.com/repos/humphd/makedrive/contributors","subscribers_url":"https://api.github.com/repos/humphd/makedrive/subscribers","subscription_url":"https://api.github.com/repos/humphd/makedrive/subscription","commits_url":"https://api.github.com/repos/humphd/makedrive/commits{/sha}","git_commits_url":"https://api.github.com/repos/humphd/makedrive/git/commits{/sha}","comments_url":"https://api.github.com/repos/humphd/makedrive/comments{/number}","issue_comment_url":"https://api.github.com/repos/humphd/makedrive/issues/comments/{number}","contents_url":"https://api.github.com/repos/humphd/makedrive/contents/{+path}","compare_url":"https://api.github.com/repos/humphd/makedrive/compare/{base}...{head}","merges_url":"https://api.github.com/repos/humphd/makedrive/merges","archive_url":"https://api.github.com/repos/humphd/makedrive/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/humphd/makedrive/downloads","issues_url":"https://api.github.com/repos/humphd/makedrive/issues{/number}","pulls_url":"https://api.github.com/repos/humphd/makedrive/pulls{/number}","milestones_url":"https://api.github.com/repos/humphd/makedrive/milestones{/number}","notifications_url":"https://api.github.com/repos/humphd/makedrive/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/humphd/makedrive/labels{/name}","releases_url":"https://api.github.com/repos/humphd/makedrive/releases{/id}","created_at":"2014-04-15T13:54:15Z","updated_at":"2014-07-09T20:58:20Z","pushed_at":"2014-07-10T16:40:10Z","git_url":"git://github.com/humphd/makedrive.git","ssh_url":"git@github.com:humphd/makedrive.git","clone_url":"https://github.com/humphd/makedrive.git","svn_url":"https://github.com/humphd/makedrive","homepage":null,"size":2685,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":4,"mirror_url":null,"open_issues_count":3,"forks":4,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"8f23d5b5904701f524dd7600b62b8e99a7681c04","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?","gravatar_id":"9ba739c8f3288e256b13553e4d257b5e","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":18801832,"name":"makedrive","full_name":"mozilla/makedrive","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?","gravatar_id":"9ba739c8f3288e256b13553e4d257b5e","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/makedrive","description":"Webmaker Filesystem","fork":false,"url":"https://api.github.com/repos/mozilla/makedrive","forks_url":"https://api.github.com/repos/mozilla/makedrive/forks","keys_url":"https://api.github.com/repos/mozilla/makedrive/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/makedrive/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/makedrive/teams","hooks_url":"https://api.github.com/repos/mozilla/makedrive/hooks","issue_events_url":"https://api.github.com/repos/mozilla/makedrive/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/makedrive/events","assignees_url":"https://api.github.com/repos/mozilla/makedrive/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/makedrive/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/makedrive/tags","blobs_url":"https://api.github.com/repos/mozilla/makedrive/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/makedrive/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/makedrive/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/makedrive/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/makedrive/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/makedrive/languages","stargazers_url":"https://api.github.com/repos/mozilla/makedrive/stargazers","contributors_url":"https://api.github.com/repos/mozilla/makedrive/contributors","subscribers_url":"https://api.github.com/repos/mozilla/makedrive/subscribers","subscription_url":"https://api.github.com/repos/mozilla/makedrive/subscription","commits_url":"https://api.github.com/repos/mozilla/makedrive/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/makedrive/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/makedrive/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/makedrive/issues/comments/{number}","contents_url":"https://api.github.com/repos/mozilla/makedrive/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/makedrive/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/makedrive/merges","archive_url":"https://api.github.com/repos/mozilla/makedrive/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/makedrive/downloads","issues_url":"https://api.github.com/repos/mozilla/makedrive/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/makedrive/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/makedrive/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/makedrive/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/makedrive/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/makedrive/releases{/id}","created_at":"2014-04-15T13:53:43Z","updated_at":"2014-07-09T20:58:26Z","pushed_at":"2014-07-10T18:41:56Z","git_url":"git://github.com/mozilla/makedrive.git","ssh_url":"git@github.com:mozilla/makedrive.git","clone_url":"https://github.com/mozilla/makedrive.git","svn_url":"https://github.com/mozilla/makedrive","homepage":null,"size":1852,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":7,"mirror_url":null,"open_issues_count":26,"forks":7,"open_issues":26,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/makedrive/pulls/64"},"html":{"href":"https://github.com/mozilla/makedrive/pull/64"},"issue":{"href":"https://api.github.com/repos/mozilla/makedrive/issues/64"},"comments":{"href":"https://api.github.com/repos/mozilla/makedrive/issues/64/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/makedrive/pulls/64/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/makedrive/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/mozilla/makedrive/pulls/64/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/makedrive/statuses/16c4274a73917a8cd2aa50a3eab9143f1c60b16c"}}}}