{"action":"created","comment":{"url":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls/comments/228209795","pull_request_review_id":168429638,"id":228209795,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyODIwOTc5NQ==","diff_hunk":"@@ -16,28 +16,43 @@ module.exports = class Config {\n   // Create config file if it doesn't exist.\n   constructor (basePath) {\n     this.configPath = path.join(basePath, 'config.json')\n+    fs.ensureFileSync(this.configPath)\n     this.dbPath = path.join(basePath, 'db')\n     fs.ensureDirSync(this.dbPath)\n     hideOnWindows(basePath)\n-    fs.ensureFileSync(this.configPath)\n \n-    if (fs.readFileSync(this.configPath).toString() === '') {\n-      this.reset()\n-    }\n+    this.config = this.read()\n \n+    // FIXME: autoBind(this)","path":"core/config.js","position":15,"original_position":15,"commit_id":"cdabbfec11348defb0b40ad031d0747fb5ca80b9","original_commit_id":"cdabbfec11348defb0b40ad031d0747fb5ca80b9","user":{"login":"taratatach","id":580382,"node_id":"MDQ6VXNlcjU4MDM4Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/580382?v=4","gravatar_id":"","url":"https://api.github.com/users/taratatach","html_url":"https://github.com/taratatach","followers_url":"https://api.github.com/users/taratatach/followers","following_url":"https://api.github.com/users/taratatach/following{/other_user}","gists_url":"https://api.github.com/users/taratatach/gists{/gist_id}","starred_url":"https://api.github.com/users/taratatach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taratatach/subscriptions","organizations_url":"https://api.github.com/users/taratatach/orgs","repos_url":"https://api.github.com/users/taratatach/repos","events_url":"https://api.github.com/users/taratatach/events{/privacy}","received_events_url":"https://api.github.com/users/taratatach/received_events","type":"User","site_admin":false},"body":"Sure thing.","created_at":"2018-10-25T14:58:38Z","updated_at":"2018-10-25T14:58:39Z","html_url":"https://github.com/cozy-labs/cozy-desktop/pull/1205#discussion_r228209795","pull_request_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls/1205","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls/comments/228209795"},"html":{"href":"https://github.com/cozy-labs/cozy-desktop/pull/1205#discussion_r228209795"},"pull_request":{"href":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls/1205"}},"in_reply_to_id":228174253},"pull_request":{"url":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls/1205","id":223228229,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzMjI4MjI5","html_url":"https://github.com/cozy-labs/cozy-desktop/pull/1205","diff_url":"https://github.com/cozy-labs/cozy-desktop/pull/1205.diff","patch_url":"https://github.com/cozy-labs/cozy-desktop/pull/1205.patch","issue_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/issues/1205","number":1205,"state":"open","locked":false,"title":"core/config: Persist config via temporary file","user":{"login":"taratatach","id":580382,"node_id":"MDQ6VXNlcjU4MDM4Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/580382?v=4","gravatar_id":"","url":"https://api.github.com/users/taratatach","html_url":"https://github.com/taratatach","followers_url":"https://api.github.com/users/taratatach/followers","following_url":"https://api.github.com/users/taratatach/following{/other_user}","gists_url":"https://api.github.com/users/taratatach/gists{/gist_id}","starred_url":"https://api.github.com/users/taratatach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taratatach/subscriptions","organizations_url":"https://api.github.com/users/taratatach/orgs","repos_url":"https://api.github.com/users/taratatach/repos","events_url":"https://api.github.com/users/taratatach/events{/privacy}","received_events_url":"https://api.github.com/users/taratatach/received_events","type":"User","site_admin":false},"body":"To avoid losing any details of the configuration if the app were to crash or be closed during the persistance process, we use a temporary file.\r\n\r\nIf the temporary file is not copied (and removed) before we close the app, the next time we fire it up, we'll load this temporary config first.\r\n\r\nIf the temporary config is not valid (e.g. we didn't have the time to finish writing its content), we remove it and load the existing config.\r\n\r\nIf we load the existing config and it's not valid, we reset it.\r\n\r\nTo make sure the tmp config path is writable and its content is only visible to the current user, we reuse the existing config path and add a `.tmp` suffix.\r\n\r\n- [x] PR is not too big\r\n- [x] it improves UX & DX in some way\r\n- [x] it includes tests matching the implementation changes\r\n- [ ] it includes relevant documentation\r\n","created_at":"2018-10-16T12:21:39Z","updated_at":"2018-10-25T14:58:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"70113a3f31235346c070b2e1651fe17ed6ac3062","assignee":{"login":"taratatach","id":580382,"node_id":"MDQ6VXNlcjU4MDM4Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/580382?v=4","gravatar_id":"","url":"https://api.github.com/users/taratatach","html_url":"https://github.com/taratatach","followers_url":"https://api.github.com/users/taratatach/followers","following_url":"https://api.github.com/users/taratatach/following{/other_user}","gists_url":"https://api.github.com/users/taratatach/gists{/gist_id}","starred_url":"https://api.github.com/users/taratatach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taratatach/subscriptions","organizations_url":"https://api.github.com/users/taratatach/orgs","repos_url":"https://api.github.com/users/taratatach/repos","events_url":"https://api.github.com/users/taratatach/events{/privacy}","received_events_url":"https://api.github.com/users/taratatach/received_events","type":"User","site_admin":false},"assignees":[{"login":"taratatach","id":580382,"node_id":"MDQ6VXNlcjU4MDM4Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/580382?v=4","gravatar_id":"","url":"https://api.github.com/users/taratatach","html_url":"https://github.com/taratatach","followers_url":"https://api.github.com/users/taratatach/followers","following_url":"https://api.github.com/users/taratatach/following{/other_user}","gists_url":"https://api.github.com/users/taratatach/gists{/gist_id}","starred_url":"https://api.github.com/users/taratatach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taratatach/subscriptions","organizations_url":"https://api.github.com/users/taratatach/orgs","repos_url":"https://api.github.com/users/taratatach/repos","events_url":"https://api.github.com/users/taratatach/events{/privacy}","received_events_url":"https://api.github.com/users/taratatach/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"sebn","id":2260801,"node_id":"MDQ6VXNlcjIyNjA4MDE=","avatar_url":"https://avatars2.githubusercontent.com/u/2260801?v=4","gravatar_id":"","url":"https://api.github.com/users/sebn","html_url":"https://github.com/sebn","followers_url":"https://api.github.com/users/sebn/followers","following_url":"https://api.github.com/users/sebn/following{/other_user}","gists_url":"https://api.github.com/users/sebn/gists{/gist_id}","starred_url":"https://api.github.com/users/sebn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebn/subscriptions","organizations_url":"https://api.github.com/users/sebn/orgs","repos_url":"https://api.github.com/users/sebn/repos","events_url":"https://api.github.com/users/sebn/events{/privacy}","received_events_url":"https://api.github.com/users/sebn/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":124895709,"node_id":"MDU6TGFiZWwxMjQ4OTU3MDk=","url":"https://api.github.com/repos/cozy-labs/cozy-desktop/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls/1205/commits","review_comments_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls/1205/comments","review_comment_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/issues/1205/comments","statuses_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/statuses/cdabbfec11348defb0b40ad031d0747fb5ca80b9","head":{"label":"cozy-labs:feat/write-config-via-tmp-file","ref":"feat/write-config-via-tmp-file","sha":"cdabbfec11348defb0b40ad031d0747fb5ca80b9","user":{"login":"cozy-labs","id":8415593,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0MTU1OTM=","avatar_url":"https://avatars0.githubusercontent.com/u/8415593?v=4","gravatar_id":"","url":"https://api.github.com/users/cozy-labs","html_url":"https://github.com/cozy-labs","followers_url":"https://api.github.com/users/cozy-labs/followers","following_url":"https://api.github.com/users/cozy-labs/following{/other_user}","gists_url":"https://api.github.com/users/cozy-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/cozy-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cozy-labs/subscriptions","organizations_url":"https://api.github.com/users/cozy-labs/orgs","repos_url":"https://api.github.com/users/cozy-labs/repos","events_url":"https://api.github.com/users/cozy-labs/events{/privacy}","received_events_url":"https://api.github.com/users/cozy-labs/received_events","type":"Organization","site_admin":false},"repo":{"id":23385363,"node_id":"MDEwOlJlcG9zaXRvcnkyMzM4NTM2Mw==","name":"cozy-desktop","full_name":"cozy-labs/cozy-desktop","private":false,"owner":{"login":"cozy-labs","id":8415593,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0MTU1OTM=","avatar_url":"https://avatars0.githubusercontent.com/u/8415593?v=4","gravatar_id":"","url":"https://api.github.com/users/cozy-labs","html_url":"https://github.com/cozy-labs","followers_url":"https://api.github.com/users/cozy-labs/followers","following_url":"https://api.github.com/users/cozy-labs/following{/other_user}","gists_url":"https://api.github.com/users/cozy-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/cozy-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cozy-labs/subscriptions","organizations_url":"https://api.github.com/users/cozy-labs/orgs","repos_url":"https://api.github.com/users/cozy-labs/repos","events_url":"https://api.github.com/users/cozy-labs/events{/privacy}","received_events_url":"https://api.github.com/users/cozy-labs/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/cozy-labs/cozy-desktop","description":"File Synchronisation for Cozy on Desktop and Laptop","fork":false,"url":"https://api.github.com/repos/cozy-labs/cozy-desktop","forks_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/forks","keys_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/teams","hooks_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/hooks","issue_events_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/issues/events{/number}","events_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/events","assignees_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/assignees{/user}","branches_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/branches{/branch}","tags_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/tags","blobs_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/git/refs{/sha}","trees_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/statuses/{sha}","languages_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/languages","stargazers_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/stargazers","contributors_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/contributors","subscribers_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/subscribers","subscription_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/subscription","commits_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/commits{/sha}","git_commits_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/git/commits{/sha}","comments_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/comments{/number}","issue_comment_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/issues/comments{/number}","contents_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/contents/{+path}","compare_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/merges","archive_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/downloads","issues_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/issues{/number}","pulls_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls{/number}","milestones_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/milestones{/number}","notifications_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/labels{/name}","releases_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/releases{/id}","deployments_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/deployments","created_at":"2014-08-27T10:10:38Z","updated_at":"2018-10-24T07:47:19Z","pushed_at":"2018-10-25T14:55:06Z","git_url":"git://github.com/cozy-labs/cozy-desktop.git","ssh_url":"git@github.com:cozy-labs/cozy-desktop.git","clone_url":"https://github.com/cozy-labs/cozy-desktop.git","svn_url":"https://github.com/cozy-labs/cozy-desktop","homepage":"https://cozy-labs.github.io/cozy-desktop/","size":9612,"stargazers_count":40,"watchers_count":40,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":31,"mirror_url":null,"archived":false,"open_issues_count":16,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":31,"open_issues":16,"watchers":40,"default_branch":"master"}},"base":{"label":"cozy-labs:master","ref":"master","sha":"8ca4565b1ce2816ed08aa61e3fab7ba31d8e11ab","user":{"login":"cozy-labs","id":8415593,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0MTU1OTM=","avatar_url":"https://avatars0.githubusercontent.com/u/8415593?v=4","gravatar_id":"","url":"https://api.github.com/users/cozy-labs","html_url":"https://github.com/cozy-labs","followers_url":"https://api.github.com/users/cozy-labs/followers","following_url":"https://api.github.com/users/cozy-labs/following{/other_user}","gists_url":"https://api.github.com/users/cozy-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/cozy-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cozy-labs/subscriptions","organizations_url":"https://api.github.com/users/cozy-labs/orgs","repos_url":"https://api.github.com/users/cozy-labs/repos","events_url":"https://api.github.com/users/cozy-labs/events{/privacy}","received_events_url":"https://api.github.com/users/cozy-labs/received_events","type":"Organization","site_admin":false},"repo":{"id":23385363,"node_id":"MDEwOlJlcG9zaXRvcnkyMzM4NTM2Mw==","name":"cozy-desktop","full_name":"cozy-labs/cozy-desktop","private":false,"owner":{"login":"cozy-labs","id":8415593,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0MTU1OTM=","avatar_url":"https://avatars0.githubusercontent.com/u/8415593?v=4","gravatar_id":"","url":"https://api.github.com/users/cozy-labs","html_url":"https://github.com/cozy-labs","followers_url":"https://api.github.com/users/cozy-labs/followers","following_url":"https://api.github.com/users/cozy-labs/following{/other_user}","gists_url":"https://api.github.com/users/cozy-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/cozy-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cozy-labs/subscriptions","organizations_url":"https://api.github.com/users/cozy-labs/orgs","repos_url":"https://api.github.com/users/cozy-labs/repos","events_url":"https://api.github.com/users/cozy-labs/events{/privacy}","received_events_url":"https://api.github.com/users/cozy-labs/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/cozy-labs/cozy-desktop","description":"File Synchronisation for Cozy on Desktop and Laptop","fork":false,"url":"https://api.github.com/repos/cozy-labs/cozy-desktop","forks_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/forks","keys_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/teams","hooks_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/hooks","issue_events_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/issues/events{/number}","events_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/events","assignees_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/assignees{/user}","branches_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/branches{/branch}","tags_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/tags","blobs_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/git/refs{/sha}","trees_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/statuses/{sha}","languages_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/languages","stargazers_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/stargazers","contributors_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/contributors","subscribers_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/subscribers","subscription_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/subscription","commits_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/commits{/sha}","git_commits_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/git/commits{/sha}","comments_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/comments{/number}","issue_comment_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/issues/comments{/number}","contents_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/contents/{+path}","compare_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/merges","archive_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/downloads","issues_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/issues{/number}","pulls_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls{/number}","milestones_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/milestones{/number}","notifications_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/labels{/name}","releases_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/releases{/id}","deployments_url":"https://api.github.com/repos/cozy-labs/cozy-desktop/deployments","created_at":"2014-08-27T10:10:38Z","updated_at":"2018-10-24T07:47:19Z","pushed_at":"2018-10-25T14:55:06Z","git_url":"git://github.com/cozy-labs/cozy-desktop.git","ssh_url":"git@github.com:cozy-labs/cozy-desktop.git","clone_url":"https://github.com/cozy-labs/cozy-desktop.git","svn_url":"https://github.com/cozy-labs/cozy-desktop","homepage":"https://cozy-labs.github.io/cozy-desktop/","size":9612,"stargazers_count":40,"watchers_count":40,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":31,"mirror_url":null,"archived":false,"open_issues_count":16,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":31,"open_issues":16,"watchers":40,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls/1205"},"html":{"href":"https://github.com/cozy-labs/cozy-desktop/pull/1205"},"issue":{"href":"https://api.github.com/repos/cozy-labs/cozy-desktop/issues/1205"},"comments":{"href":"https://api.github.com/repos/cozy-labs/cozy-desktop/issues/1205/comments"},"review_comments":{"href":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls/1205/comments"},"review_comment":{"href":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cozy-labs/cozy-desktop/pulls/1205/commits"},"statuses":{"href":"https://api.github.com/repos/cozy-labs/cozy-desktop/statuses/cdabbfec11348defb0b40ad031d0747fb5ca80b9"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"taratatach"}}