{"action":"created","comment":{"url":"https://api.github.com/repos/cozy/cozy-data-system/pulls/comments/25416856","id":25416856,"diff_hunk":"@@ -1,28 +1,34 @@\n-db = require('../helpers/db_connect_helper').db_connect()\n-encryption = require('./encryption')\n-\n-## Patch for automatic encryption\n-# We must think about removing this (12/02/2014)\n+log = require('printit')\n+    date: true\n+    prefix: 'lib/init'\n \n-errorMsg = \"[lib/init] Error, no master/slave keys\"\n-exports.initPassword = (callback) ->\n-    if process.env isnt 'development'\n-        db.view \"bankaccess/all\", {}, (err, res) =>\n-            if not err\n-                res.forEach (value) ->\n-                    if value.password?\n-                        try\n-                            password = encryption.decrypt value.password\n-                        catch error\n-                            console.log errorMsg\n-\n-                        if password is value.password\n-                            try\n-                                password = encryption.encrypt req.doc.password\n-                            catch error\n-                                console.log errorMsg\n+db = require('../helpers/db_connect_helper').db_connect()\n+async = require 'async'\n \n-                            value.password = password\n-                            db.save value.id, value, (err, res, body) ->\n-    callback()\n \n+# Remove binaries not linked with a document\n+exports.removeLostBinaries = (callback) ->\n+    # Recover all binaries\n+    db.view 'binary/all', (err, binaries) =>\n+        if not err and binaries.length > 0\n+            async.forEachSeries binaries, (binary, cb) ->\n+                # Check if binary is linked to a document\n+                db.view 'binary/byDoc', key: binary.id, (err, doc) =>","path":"server/lib/init.coffee","position":41,"original_position":41,"commit_id":"063364aba9d309650ed80e87136a6428d9c201f0","original_commit_id":"063364aba9d309650ed80e87136a6428d9c201f0","user":{"login":"aenario","id":1580287,"avatar_url":"https://avatars.githubusercontent.com/u/1580287?v=3","gravatar_id":"","url":"https://api.github.com/users/aenario","html_url":"https://github.com/aenario","followers_url":"https://api.github.com/users/aenario/followers","following_url":"https://api.github.com/users/aenario/following{/other_user}","gists_url":"https://api.github.com/users/aenario/gists{/gist_id}","starred_url":"https://api.github.com/users/aenario/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aenario/subscriptions","organizations_url":"https://api.github.com/users/aenario/orgs","repos_url":"https://api.github.com/users/aenario/repos","events_url":"https://api.github.com/users/aenario/events{/privacy}","received_events_url":"https://api.github.com/users/aenario/received_events","type":"User","site_admin":false},"body":"it would be fine if binary/all did not emit doc (only ids) and you query once binary/byDoc to fetch the list of key: binary.id. Then you compare two array of ids.","created_at":"2015-02-26T10:23:45Z","updated_at":"2015-02-26T10:23:45Z","html_url":"https://github.com/cozy/cozy-data-system/pull/125#discussion_r25416856","pull_request_url":"https://api.github.com/repos/cozy/cozy-data-system/pulls/125","_links":{"self":{"href":"https://api.github.com/repos/cozy/cozy-data-system/pulls/comments/25416856"},"html":{"href":"https://github.com/cozy/cozy-data-system/pull/125#discussion_r25416856"},"pull_request":{"href":"https://api.github.com/repos/cozy/cozy-data-system/pulls/125"}}},"pull_request":{"url":"https://api.github.com/repos/cozy/cozy-data-system/pulls/125","id":30058589,"html_url":"https://github.com/cozy/cozy-data-system/pull/125","diff_url":"https://github.com/cozy/cozy-data-system/pull/125.diff","patch_url":"https://github.com/cozy/cozy-data-system/pull/125.patch","issue_url":"https://api.github.com/repos/cozy/cozy-data-system/issues/125","number":125,"state":"open","locked":false,"title":"Binary cleaning","user":{"login":"poupotte","id":2659119,"avatar_url":"https://avatars.githubusercontent.com/u/2659119?v=3","gravatar_id":"","url":"https://api.github.com/users/poupotte","html_url":"https://github.com/poupotte","followers_url":"https://api.github.com/users/poupotte/followers","following_url":"https://api.github.com/users/poupotte/following{/other_user}","gists_url":"https://api.github.com/users/poupotte/gists{/gist_id}","starred_url":"https://api.github.com/users/poupotte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poupotte/subscriptions","organizations_url":"https://api.github.com/users/poupotte/orgs","repos_url":"https://api.github.com/users/poupotte/repos","events_url":"https://api.github.com/users/poupotte/events{/privacy}","received_events_url":"https://api.github.com/users/poupotte/received_events","type":"User","site_admin":false},"body":"Refs #121","created_at":"2015-02-26T08:31:03Z","updated_at":"2015-02-26T10:23:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"14e72795738d74e60f1657d81880fc436f5cd531","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cozy/cozy-data-system/pulls/125/commits","review_comments_url":"https://api.github.com/repos/cozy/cozy-data-system/pulls/125/comments","review_comment_url":"https://api.github.com/repos/cozy/cozy-data-system/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cozy/cozy-data-system/issues/125/comments","statuses_url":"https://api.github.com/repos/cozy/cozy-data-system/statuses/063364aba9d309650ed80e87136a6428d9c201f0","head":{"label":"poupotte:master","ref":"master","sha":"063364aba9d309650ed80e87136a6428d9c201f0","user":{"login":"poupotte","id":2659119,"avatar_url":"https://avatars.githubusercontent.com/u/2659119?v=3","gravatar_id":"","url":"https://api.github.com/users/poupotte","html_url":"https://github.com/poupotte","followers_url":"https://api.github.com/users/poupotte/followers","following_url":"https://api.github.com/users/poupotte/following{/other_user}","gists_url":"https://api.github.com/users/poupotte/gists{/gist_id}","starred_url":"https://api.github.com/users/poupotte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poupotte/subscriptions","organizations_url":"https://api.github.com/users/poupotte/orgs","repos_url":"https://api.github.com/users/poupotte/repos","events_url":"https://api.github.com/users/poupotte/events{/privacy}","received_events_url":"https://api.github.com/users/poupotte/received_events","type":"User","site_admin":false},"repo":{"id":9026525,"name":"cozy-data-system","full_name":"poupotte/cozy-data-system","owner":{"login":"poupotte","id":2659119,"avatar_url":"https://avatars.githubusercontent.com/u/2659119?v=3","gravatar_id":"","url":"https://api.github.com/users/poupotte","html_url":"https://github.com/poupotte","followers_url":"https://api.github.com/users/poupotte/followers","following_url":"https://api.github.com/users/poupotte/following{/other_user}","gists_url":"https://api.github.com/users/poupotte/gists{/gist_id}","starred_url":"https://api.github.com/users/poupotte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poupotte/subscriptions","organizations_url":"https://api.github.com/users/poupotte/orgs","repos_url":"https://api.github.com/users/poupotte/repos","events_url":"https://api.github.com/users/poupotte/events{/privacy}","received_events_url":"https://api.github.com/users/poupotte/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/poupotte/cozy-data-system","description":"Data Layer for Cozy Cloud platform","fork":true,"url":"https://api.github.com/repos/poupotte/cozy-data-system","forks_url":"https://api.github.com/repos/poupotte/cozy-data-system/forks","keys_url":"https://api.github.com/repos/poupotte/cozy-data-system/keys{/key_id}","collaborators_url":"https://api.github.com/repos/poupotte/cozy-data-system/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/poupotte/cozy-data-system/teams","hooks_url":"https://api.github.com/repos/poupotte/cozy-data-system/hooks","issue_events_url":"https://api.github.com/repos/poupotte/cozy-data-system/issues/events{/number}","events_url":"https://api.github.com/repos/poupotte/cozy-data-system/events","assignees_url":"https://api.github.com/repos/poupotte/cozy-data-system/assignees{/user}","branches_url":"https://api.github.com/repos/poupotte/cozy-data-system/branches{/branch}","tags_url":"https://api.github.com/repos/poupotte/cozy-data-system/tags","blobs_url":"https://api.github.com/repos/poupotte/cozy-data-system/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/poupotte/cozy-data-system/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/poupotte/cozy-data-system/git/refs{/sha}","trees_url":"https://api.github.com/repos/poupotte/cozy-data-system/git/trees{/sha}","statuses_url":"https://api.github.com/repos/poupotte/cozy-data-system/statuses/{sha}","languages_url":"https://api.github.com/repos/poupotte/cozy-data-system/languages","stargazers_url":"https://api.github.com/repos/poupotte/cozy-data-system/stargazers","contributors_url":"https://api.github.com/repos/poupotte/cozy-data-system/contributors","subscribers_url":"https://api.github.com/repos/poupotte/cozy-data-system/subscribers","subscription_url":"https://api.github.com/repos/poupotte/cozy-data-system/subscription","commits_url":"https://api.github.com/repos/poupotte/cozy-data-system/commits{/sha}","git_commits_url":"https://api.github.com/repos/poupotte/cozy-data-system/git/commits{/sha}","comments_url":"https://api.github.com/repos/poupotte/cozy-data-system/comments{/number}","issue_comment_url":"https://api.github.com/repos/poupotte/cozy-data-system/issues/comments{/number}","contents_url":"https://api.github.com/repos/poupotte/cozy-data-system/contents/{+path}","compare_url":"https://api.github.com/repos/poupotte/cozy-data-system/compare/{base}...{head}","merges_url":"https://api.github.com/repos/poupotte/cozy-data-system/merges","archive_url":"https://api.github.com/repos/poupotte/cozy-data-system/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/poupotte/cozy-data-system/downloads","issues_url":"https://api.github.com/repos/poupotte/cozy-data-system/issues{/number}","pulls_url":"https://api.github.com/repos/poupotte/cozy-data-system/pulls{/number}","milestones_url":"https://api.github.com/repos/poupotte/cozy-data-system/milestones{/number}","notifications_url":"https://api.github.com/repos/poupotte/cozy-data-system/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/poupotte/cozy-data-system/labels{/name}","releases_url":"https://api.github.com/repos/poupotte/cozy-data-system/releases{/id}","created_at":"2013-03-26T09:03:56Z","updated_at":"2015-02-26T08:30:05Z","pushed_at":"2015-02-26T08:30:04Z","git_url":"git://github.com/poupotte/cozy-data-system.git","ssh_url":"git@github.com:poupotte/cozy-data-system.git","clone_url":"https://github.com/poupotte/cozy-data-system.git","svn_url":"https://github.com/poupotte/cozy-data-system","homepage":"cozycloud.cc","size":2213,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","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":"cozy:master","ref":"master","sha":"06988c33e28e04e97595e5c65d1909ab7ab44704","user":{"login":"cozy","id":7690525,"avatar_url":"https://avatars.githubusercontent.com/u/7690525?v=3","gravatar_id":"","url":"https://api.github.com/users/cozy","html_url":"https://github.com/cozy","followers_url":"https://api.github.com/users/cozy/followers","following_url":"https://api.github.com/users/cozy/following{/other_user}","gists_url":"https://api.github.com/users/cozy/gists{/gist_id}","starred_url":"https://api.github.com/users/cozy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cozy/subscriptions","organizations_url":"https://api.github.com/users/cozy/orgs","repos_url":"https://api.github.com/users/cozy/repos","events_url":"https://api.github.com/users/cozy/events{/privacy}","received_events_url":"https://api.github.com/users/cozy/received_events","type":"Organization","site_admin":false},"repo":{"id":5093292,"name":"cozy-data-system","full_name":"cozy/cozy-data-system","owner":{"login":"cozy","id":7690525,"avatar_url":"https://avatars.githubusercontent.com/u/7690525?v=3","gravatar_id":"","url":"https://api.github.com/users/cozy","html_url":"https://github.com/cozy","followers_url":"https://api.github.com/users/cozy/followers","following_url":"https://api.github.com/users/cozy/following{/other_user}","gists_url":"https://api.github.com/users/cozy/gists{/gist_id}","starred_url":"https://api.github.com/users/cozy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cozy/subscriptions","organizations_url":"https://api.github.com/users/cozy/orgs","repos_url":"https://api.github.com/users/cozy/repos","events_url":"https://api.github.com/users/cozy/events{/privacy}","received_events_url":"https://api.github.com/users/cozy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cozy/cozy-data-system","description":"Data Layer for Cozy Platform","fork":false,"url":"https://api.github.com/repos/cozy/cozy-data-system","forks_url":"https://api.github.com/repos/cozy/cozy-data-system/forks","keys_url":"https://api.github.com/repos/cozy/cozy-data-system/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cozy/cozy-data-system/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cozy/cozy-data-system/teams","hooks_url":"https://api.github.com/repos/cozy/cozy-data-system/hooks","issue_events_url":"https://api.github.com/repos/cozy/cozy-data-system/issues/events{/number}","events_url":"https://api.github.com/repos/cozy/cozy-data-system/events","assignees_url":"https://api.github.com/repos/cozy/cozy-data-system/assignees{/user}","branches_url":"https://api.github.com/repos/cozy/cozy-data-system/branches{/branch}","tags_url":"https://api.github.com/repos/cozy/cozy-data-system/tags","blobs_url":"https://api.github.com/repos/cozy/cozy-data-system/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cozy/cozy-data-system/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cozy/cozy-data-system/git/refs{/sha}","trees_url":"https://api.github.com/repos/cozy/cozy-data-system/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cozy/cozy-data-system/statuses/{sha}","languages_url":"https://api.github.com/repos/cozy/cozy-data-system/languages","stargazers_url":"https://api.github.com/repos/cozy/cozy-data-system/stargazers","contributors_url":"https://api.github.com/repos/cozy/cozy-data-system/contributors","subscribers_url":"https://api.github.com/repos/cozy/cozy-data-system/subscribers","subscription_url":"https://api.github.com/repos/cozy/cozy-data-system/subscription","commits_url":"https://api.github.com/repos/cozy/cozy-data-system/commits{/sha}","git_commits_url":"https://api.github.com/repos/cozy/cozy-data-system/git/commits{/sha}","comments_url":"https://api.github.com/repos/cozy/cozy-data-system/comments{/number}","issue_comment_url":"https://api.github.com/repos/cozy/cozy-data-system/issues/comments{/number}","contents_url":"https://api.github.com/repos/cozy/cozy-data-system/contents/{+path}","compare_url":"https://api.github.com/repos/cozy/cozy-data-system/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cozy/cozy-data-system/merges","archive_url":"https://api.github.com/repos/cozy/cozy-data-system/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cozy/cozy-data-system/downloads","issues_url":"https://api.github.com/repos/cozy/cozy-data-system/issues{/number}","pulls_url":"https://api.github.com/repos/cozy/cozy-data-system/pulls{/number}","milestones_url":"https://api.github.com/repos/cozy/cozy-data-system/milestones{/number}","notifications_url":"https://api.github.com/repos/cozy/cozy-data-system/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cozy/cozy-data-system/labels{/name}","releases_url":"https://api.github.com/repos/cozy/cozy-data-system/releases{/id}","created_at":"2012-07-18T07:58:49Z","updated_at":"2015-02-20T10:04:49Z","pushed_at":"2015-02-20T10:04:48Z","git_url":"git://github.com/cozy/cozy-data-system.git","ssh_url":"git@github.com:cozy/cozy-data-system.git","clone_url":"https://github.com/cozy/cozy-data-system.git","svn_url":"https://github.com/cozy/cozy-data-system","homepage":"cozy.io","size":2651,"stargazers_count":17,"watchers_count":17,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":7,"forks":8,"open_issues":7,"watchers":17,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cozy/cozy-data-system/pulls/125"},"html":{"href":"https://github.com/cozy/cozy-data-system/pull/125"},"issue":{"href":"https://api.github.com/repos/cozy/cozy-data-system/issues/125"},"comments":{"href":"https://api.github.com/repos/cozy/cozy-data-system/issues/125/comments"},"review_comments":{"href":"https://api.github.com/repos/cozy/cozy-data-system/pulls/125/comments"},"review_comment":{"href":"https://api.github.com/repos/cozy/cozy-data-system/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cozy/cozy-data-system/pulls/125/commits"},"statuses":{"href":"https://api.github.com/repos/cozy/cozy-data-system/statuses/063364aba9d309650ed80e87136a6428d9c201f0"}}}}