{"action":"created","comment":{"url":"https://api.github.com/repos/prey/prey-node-client/pulls/comments/62751894","id":62751894,"diff_hunk":"@@ -0,0 +1,116 @@\n+#!/usr/bin/env node\n+\n+/**\n+ * Traverses directories and return its content.\n+ * Needed as stand-alone in order to be ran as an specific user\n+ * due to read permissions in *nix systems.\n+ */\n+\n+var fs = require('fs'),\n+  path = require('path'),\n+  mime = require('mime'),\n+  winattr = require('winattr'),\n+  argv = process.argv,\n+  p = argv[3],\n+  d = argv[2] || 1,\n+  cd = 1,\n+  os_name = process.platform.replace('darwin', 'mac').replace('win32', 'windows');\n+\n+var directoryTreeToObj = function(dir, current_depth, depth, done) {\n+  var resultsDir = [];\n+  var resultsFile = [];\n+\n+  fs.readdir(dir, function(err, list) {\n+    if (err)\n+      return done(err);\n+\n+    var pending = list.length;\n+    if (!pending){\n+      if (pending <= 0){\n+        return done(null, resultsDir.concat(resultsFile));\n+      }\n+      else{\n+        return done(null, {\n+          name: path.basename(dir),\n+          type: 'folder',\n+          children: resultsDir.concat(resultsFile)\n+        });\n+      }\n+    }\n+    list.forEach(function(file) {\n+      file = path.resolve(dir, file);\n+      fs.stat(file, function(err, stat) {\n+        // Documents and Setting folder on Windows is not accesible because is a link for\n+        // compatibility between the OS versions, so it shouldn't be visible in FR.\n+        if (err || (os_name == \"windows\" && path.basename(file) == \"Documents and Settings\")) {\n+          pending--;\n+        }\n+        else {\n+          if (stat && stat.isDirectory() && current_depth < depth) { \n+            directoryTreeToObj(file, current_depth + 1, depth, function(err, res) {\n+              var dirname = path.dirname(file),\n+                  name = path.basename(file),\n+                  p = path.join(dirname, name);\n+\n+              checkIfHiddenFile(p, name, function(isHidden) {\n+                var newFile = {\n+                  name: name,\n+                  path: p,\n+                  isFile: stat.isFile(),\n+                  hidden: isHidden,\n+                  children: res\n+                };\n+                resultsDir.push(newFile);\n+                if (!--pending)\n+                  done(null, resultsDir.concat(resultsFile));\n+              });\n+\n+            });\n+          } else if (stat) {\n+            var dirname = path.dirname(file),\n+                name = path.basename(file),\n+                p = path.join(dirname, name);\n+\n+            checkIfHiddenFile(p, name, function(isHidden) {\n+              var newFile = {\n+                name: name,\n+                path: p,\n+                mimetype: mime.lookup(file),\n+                size: stat.size,\n+                isFile: stat.isFile(),\n+                hidden: isHidden\n+              };\n+             \n+              if (stat.isFile())\n+                resultsFile.push(newFile);\n+              else\n+                resultsDir.push(newFile);\n+              if (!--pending)\n+                done(null, resultsDir.concat(resultsFile));\n+            });\n+          }\n+        }\n+      });\n+    });\n+  });\n+};\n+\n+directoryTreeToObj(p, cd, d, function(err, res) {\n+  if (err)\n+    console.error(err);\n+\n+  console.log(JSON.stringify(res));","path":"lib/agent/providers/files/tree.js","position":102,"original_position":102,"commit_id":"533fd3a0bcb45fc2995b961555f44ae5251e089a","original_commit_id":"533fd3a0bcb45fc2995b961555f44ae5251e089a","user":{"login":"raliste","id":388935,"avatar_url":"https://avatars.githubusercontent.com/u/388935?v=3","gravatar_id":"","url":"https://api.github.com/users/raliste","html_url":"https://github.com/raliste","followers_url":"https://api.github.com/users/raliste/followers","following_url":"https://api.github.com/users/raliste/following{/other_user}","gists_url":"https://api.github.com/users/raliste/gists{/gist_id}","starred_url":"https://api.github.com/users/raliste/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raliste/subscriptions","organizations_url":"https://api.github.com/users/raliste/orgs","repos_url":"https://api.github.com/users/raliste/repos","events_url":"https://api.github.com/users/raliste/events{/privacy}","received_events_url":"https://api.github.com/users/raliste/received_events","type":"User","site_admin":false},"body":"remove this or put inside logger.info","created_at":"2016-05-10T21:03:39Z","updated_at":"2016-05-10T21:03:39Z","html_url":"https://github.com/prey/prey-node-client/pull/184#discussion_r62751894","pull_request_url":"https://api.github.com/repos/prey/prey-node-client/pulls/184","_links":{"self":{"href":"https://api.github.com/repos/prey/prey-node-client/pulls/comments/62751894"},"html":{"href":"https://github.com/prey/prey-node-client/pull/184#discussion_r62751894"},"pull_request":{"href":"https://api.github.com/repos/prey/prey-node-client/pulls/184"}}},"pull_request":{"url":"https://api.github.com/repos/prey/prey-node-client/pulls/184","id":55388806,"html_url":"https://github.com/prey/prey-node-client/pull/184","diff_url":"https://github.com/prey/prey-node-client/pull/184.diff","patch_url":"https://github.com/prey/prey-node-client/pull/184.patch","issue_url":"https://api.github.com/repos/prey/prey-node-client/issues/184","number":184,"state":"open","locked":false,"title":"Filebrowser dev","user":{"login":"javo","id":11738416,"avatar_url":"https://avatars.githubusercontent.com/u/11738416?v=3","gravatar_id":"","url":"https://api.github.com/users/javo","html_url":"https://github.com/javo","followers_url":"https://api.github.com/users/javo/followers","following_url":"https://api.github.com/users/javo/following{/other_user}","gists_url":"https://api.github.com/users/javo/gists{/gist_id}","starred_url":"https://api.github.com/users/javo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javo/subscriptions","organizations_url":"https://api.github.com/users/javo/orgs","repos_url":"https://api.github.com/users/javo/repos","events_url":"https://api.github.com/users/javo/events{/privacy}","received_events_url":"https://api.github.com/users/javo/received_events","type":"User","site_admin":false},"body":"Fixes for fileretrieval including depth and maxBuffer","created_at":"2016-01-07T20:53:17Z","updated_at":"2016-05-10T21:03:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7cfa945dd6854efe9efb2d868960976f7c19dba7","assignee":{"login":"javo","id":11738416,"avatar_url":"https://avatars.githubusercontent.com/u/11738416?v=3","gravatar_id":"","url":"https://api.github.com/users/javo","html_url":"https://github.com/javo","followers_url":"https://api.github.com/users/javo/followers","following_url":"https://api.github.com/users/javo/following{/other_user}","gists_url":"https://api.github.com/users/javo/gists{/gist_id}","starred_url":"https://api.github.com/users/javo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javo/subscriptions","organizations_url":"https://api.github.com/users/javo/orgs","repos_url":"https://api.github.com/users/javo/repos","events_url":"https://api.github.com/users/javo/events{/privacy}","received_events_url":"https://api.github.com/users/javo/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/prey/prey-node-client/pulls/184/commits","review_comments_url":"https://api.github.com/repos/prey/prey-node-client/pulls/184/comments","review_comment_url":"https://api.github.com/repos/prey/prey-node-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prey/prey-node-client/issues/184/comments","statuses_url":"https://api.github.com/repos/prey/prey-node-client/statuses/533fd3a0bcb45fc2995b961555f44ae5251e089a","head":{"label":"prey:filebrowser-dev","ref":"filebrowser-dev","sha":"533fd3a0bcb45fc2995b961555f44ae5251e089a","user":{"login":"prey","id":833975,"avatar_url":"https://avatars.githubusercontent.com/u/833975?v=3","gravatar_id":"","url":"https://api.github.com/users/prey","html_url":"https://github.com/prey","followers_url":"https://api.github.com/users/prey/followers","following_url":"https://api.github.com/users/prey/following{/other_user}","gists_url":"https://api.github.com/users/prey/gists{/gist_id}","starred_url":"https://api.github.com/users/prey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prey/subscriptions","organizations_url":"https://api.github.com/users/prey/orgs","repos_url":"https://api.github.com/users/prey/repos","events_url":"https://api.github.com/users/prey/events{/privacy}","received_events_url":"https://api.github.com/users/prey/received_events","type":"Organization","site_admin":false},"repo":{"id":3743084,"name":"prey-node-client","full_name":"prey/prey-node-client","owner":{"login":"prey","id":833975,"avatar_url":"https://avatars.githubusercontent.com/u/833975?v=3","gravatar_id":"","url":"https://api.github.com/users/prey","html_url":"https://github.com/prey","followers_url":"https://api.github.com/users/prey/followers","following_url":"https://api.github.com/users/prey/following{/other_user}","gists_url":"https://api.github.com/users/prey/gists{/gist_id}","starred_url":"https://api.github.com/users/prey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prey/subscriptions","organizations_url":"https://api.github.com/users/prey/orgs","repos_url":"https://api.github.com/users/prey/repos","events_url":"https://api.github.com/users/prey/events{/privacy}","received_events_url":"https://api.github.com/users/prey/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prey/prey-node-client","description":"Node.js client for the Prey anti-theft software.","fork":false,"url":"https://api.github.com/repos/prey/prey-node-client","forks_url":"https://api.github.com/repos/prey/prey-node-client/forks","keys_url":"https://api.github.com/repos/prey/prey-node-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prey/prey-node-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prey/prey-node-client/teams","hooks_url":"https://api.github.com/repos/prey/prey-node-client/hooks","issue_events_url":"https://api.github.com/repos/prey/prey-node-client/issues/events{/number}","events_url":"https://api.github.com/repos/prey/prey-node-client/events","assignees_url":"https://api.github.com/repos/prey/prey-node-client/assignees{/user}","branches_url":"https://api.github.com/repos/prey/prey-node-client/branches{/branch}","tags_url":"https://api.github.com/repos/prey/prey-node-client/tags","blobs_url":"https://api.github.com/repos/prey/prey-node-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prey/prey-node-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prey/prey-node-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/prey/prey-node-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prey/prey-node-client/statuses/{sha}","languages_url":"https://api.github.com/repos/prey/prey-node-client/languages","stargazers_url":"https://api.github.com/repos/prey/prey-node-client/stargazers","contributors_url":"https://api.github.com/repos/prey/prey-node-client/contributors","subscribers_url":"https://api.github.com/repos/prey/prey-node-client/subscribers","subscription_url":"https://api.github.com/repos/prey/prey-node-client/subscription","commits_url":"https://api.github.com/repos/prey/prey-node-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/prey/prey-node-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/prey/prey-node-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/prey/prey-node-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/prey/prey-node-client/contents/{+path}","compare_url":"https://api.github.com/repos/prey/prey-node-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prey/prey-node-client/merges","archive_url":"https://api.github.com/repos/prey/prey-node-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prey/prey-node-client/downloads","issues_url":"https://api.github.com/repos/prey/prey-node-client/issues{/number}","pulls_url":"https://api.github.com/repos/prey/prey-node-client/pulls{/number}","milestones_url":"https://api.github.com/repos/prey/prey-node-client/milestones{/number}","notifications_url":"https://api.github.com/repos/prey/prey-node-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prey/prey-node-client/labels{/name}","releases_url":"https://api.github.com/repos/prey/prey-node-client/releases{/id}","deployments_url":"https://api.github.com/repos/prey/prey-node-client/deployments","created_at":"2012-03-16T21:09:27Z","updated_at":"2016-05-02T07:56:22Z","pushed_at":"2016-05-10T20:30:54Z","git_url":"git://github.com/prey/prey-node-client.git","ssh_url":"git@github.com:prey/prey-node-client.git","clone_url":"https://github.com/prey/prey-node-client.git","svn_url":"https://github.com/prey/prey-node-client","homepage":"http://preyproject.com","size":23528,"stargazers_count":201,"watchers_count":201,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":55,"mirror_url":null,"open_issues_count":74,"forks":55,"open_issues":74,"watchers":201,"default_branch":"master"}},"base":{"label":"prey:master","ref":"master","sha":"25147be77a4b068225fe76f27601e5d887869406","user":{"login":"prey","id":833975,"avatar_url":"https://avatars.githubusercontent.com/u/833975?v=3","gravatar_id":"","url":"https://api.github.com/users/prey","html_url":"https://github.com/prey","followers_url":"https://api.github.com/users/prey/followers","following_url":"https://api.github.com/users/prey/following{/other_user}","gists_url":"https://api.github.com/users/prey/gists{/gist_id}","starred_url":"https://api.github.com/users/prey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prey/subscriptions","organizations_url":"https://api.github.com/users/prey/orgs","repos_url":"https://api.github.com/users/prey/repos","events_url":"https://api.github.com/users/prey/events{/privacy}","received_events_url":"https://api.github.com/users/prey/received_events","type":"Organization","site_admin":false},"repo":{"id":3743084,"name":"prey-node-client","full_name":"prey/prey-node-client","owner":{"login":"prey","id":833975,"avatar_url":"https://avatars.githubusercontent.com/u/833975?v=3","gravatar_id":"","url":"https://api.github.com/users/prey","html_url":"https://github.com/prey","followers_url":"https://api.github.com/users/prey/followers","following_url":"https://api.github.com/users/prey/following{/other_user}","gists_url":"https://api.github.com/users/prey/gists{/gist_id}","starred_url":"https://api.github.com/users/prey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prey/subscriptions","organizations_url":"https://api.github.com/users/prey/orgs","repos_url":"https://api.github.com/users/prey/repos","events_url":"https://api.github.com/users/prey/events{/privacy}","received_events_url":"https://api.github.com/users/prey/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prey/prey-node-client","description":"Node.js client for the Prey anti-theft software.","fork":false,"url":"https://api.github.com/repos/prey/prey-node-client","forks_url":"https://api.github.com/repos/prey/prey-node-client/forks","keys_url":"https://api.github.com/repos/prey/prey-node-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prey/prey-node-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prey/prey-node-client/teams","hooks_url":"https://api.github.com/repos/prey/prey-node-client/hooks","issue_events_url":"https://api.github.com/repos/prey/prey-node-client/issues/events{/number}","events_url":"https://api.github.com/repos/prey/prey-node-client/events","assignees_url":"https://api.github.com/repos/prey/prey-node-client/assignees{/user}","branches_url":"https://api.github.com/repos/prey/prey-node-client/branches{/branch}","tags_url":"https://api.github.com/repos/prey/prey-node-client/tags","blobs_url":"https://api.github.com/repos/prey/prey-node-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prey/prey-node-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prey/prey-node-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/prey/prey-node-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prey/prey-node-client/statuses/{sha}","languages_url":"https://api.github.com/repos/prey/prey-node-client/languages","stargazers_url":"https://api.github.com/repos/prey/prey-node-client/stargazers","contributors_url":"https://api.github.com/repos/prey/prey-node-client/contributors","subscribers_url":"https://api.github.com/repos/prey/prey-node-client/subscribers","subscription_url":"https://api.github.com/repos/prey/prey-node-client/subscription","commits_url":"https://api.github.com/repos/prey/prey-node-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/prey/prey-node-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/prey/prey-node-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/prey/prey-node-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/prey/prey-node-client/contents/{+path}","compare_url":"https://api.github.com/repos/prey/prey-node-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prey/prey-node-client/merges","archive_url":"https://api.github.com/repos/prey/prey-node-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prey/prey-node-client/downloads","issues_url":"https://api.github.com/repos/prey/prey-node-client/issues{/number}","pulls_url":"https://api.github.com/repos/prey/prey-node-client/pulls{/number}","milestones_url":"https://api.github.com/repos/prey/prey-node-client/milestones{/number}","notifications_url":"https://api.github.com/repos/prey/prey-node-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prey/prey-node-client/labels{/name}","releases_url":"https://api.github.com/repos/prey/prey-node-client/releases{/id}","deployments_url":"https://api.github.com/repos/prey/prey-node-client/deployments","created_at":"2012-03-16T21:09:27Z","updated_at":"2016-05-02T07:56:22Z","pushed_at":"2016-05-10T20:30:54Z","git_url":"git://github.com/prey/prey-node-client.git","ssh_url":"git@github.com:prey/prey-node-client.git","clone_url":"https://github.com/prey/prey-node-client.git","svn_url":"https://github.com/prey/prey-node-client","homepage":"http://preyproject.com","size":23528,"stargazers_count":201,"watchers_count":201,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":55,"mirror_url":null,"open_issues_count":74,"forks":55,"open_issues":74,"watchers":201,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prey/prey-node-client/pulls/184"},"html":{"href":"https://github.com/prey/prey-node-client/pull/184"},"issue":{"href":"https://api.github.com/repos/prey/prey-node-client/issues/184"},"comments":{"href":"https://api.github.com/repos/prey/prey-node-client/issues/184/comments"},"review_comments":{"href":"https://api.github.com/repos/prey/prey-node-client/pulls/184/comments"},"review_comment":{"href":"https://api.github.com/repos/prey/prey-node-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prey/prey-node-client/pulls/184/commits"},"statuses":{"href":"https://api.github.com/repos/prey/prey-node-client/statuses/533fd3a0bcb45fc2995b961555f44ae5251e089a"}}}}