{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/vscode/pulls/comments/83235223","pull_request_review_id":4091365,"id":83235223,"diff_hunk":"@@ -0,0 +1,88 @@\n+/*---------------------------------------------------------------------------------------------\n+ *  Copyright (c) Microsoft Corporation. All rights reserved.\n+ *  Licensed under the MIT License. See License.txt in the project root for license information.\n+ *--------------------------------------------------------------------------------------------*/\n+\n+'use strict';\n+\n+import * as fs from 'original-fs';\n+import * as path from 'path';\n+import { createDecorator } from 'vs/platform/instantiation/common/instantiation';\n+import { IEnvironmentService } from 'vs/platform/environment/common/environment';\n+\n+export const IBackupService = createDecorator<IBackupService>('backupService');\n+\n+export interface IBackupService {\n+\tgetBackupWorkspaces(): string[];\n+\tclearBackupWorkspaces(): void;\n+\tpushBackupWorkspaces(workspaces: string[]): void;\n+\tgetBackupFiles(workspace: string): string[];\n+}\n+\n+interface IBackupFormat {\n+\tfolderWorkspaces?: {\n+\t\t[workspacePath: string]: string[]\n+\t};\n+}\n+\n+export class BackupService implements IBackupService {\n+\n+\tprivate filePath: string;\n+\tprivate fileContent: IBackupFormat;\n+\n+\tconstructor(\n+\t\t@IEnvironmentService private environmentService: IEnvironmentService\n+\t) {\n+\t\tthis.filePath = path.join(environmentService.userDataPath, 'Backups', 'workspaces.json');\n+\t}\n+\n+\tpublic getBackupWorkspaces(): string[] {\n+\t\tif (!this.fileContent) {\n+\t\t\tthis.load();\n+\t\t}\n+\t\treturn Object.keys(this.fileContent.folderWorkspaces || {});\n+\t}\n+\n+\tpublic clearBackupWorkspaces(): void {\n+\t\tthis.fileContent = {\n+\t\t\tfolderWorkspaces: {}","path":"src/vs/code/electron-main/backup.ts","position":48,"original_position":48,"commit_id":"550da5e2330dfd5480d2c462612fd1fbb433b4e2","original_commit_id":"550da5e2330dfd5480d2c462612fd1fbb433b4e2","user":{"login":"bpasero","id":900690,"avatar_url":"https://avatars.githubusercontent.com/u/900690?v=3","gravatar_id":"","url":"https://api.github.com/users/bpasero","html_url":"https://github.com/bpasero","followers_url":"https://api.github.com/users/bpasero/followers","following_url":"https://api.github.com/users/bpasero/following{/other_user}","gists_url":"https://api.github.com/users/bpasero/gists{/gist_id}","starred_url":"https://api.github.com/users/bpasero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpasero/subscriptions","organizations_url":"https://api.github.com/users/bpasero/orgs","repos_url":"https://api.github.com/users/bpasero/repos","events_url":"https://api.github.com/users/bpasero/events{/privacy}","received_events_url":"https://api.github.com/users/bpasero/received_events","type":"User","site_admin":false},"body":"Just a personal preference to use `Object.create(null)` over `{}`","created_at":"2016-10-13T14:54:58Z","updated_at":"2016-10-13T14:54:58Z","html_url":"https://github.com/Microsoft/vscode/pull/12400#discussion_r83235223","pull_request_url":"https://api.github.com/repos/Microsoft/vscode/pulls/12400","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/vscode/pulls/comments/83235223"},"html":{"href":"https://github.com/Microsoft/vscode/pull/12400#discussion_r83235223"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/vscode/pulls/12400"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/vscode/pulls/12400","id":86213669,"html_url":"https://github.com/Microsoft/vscode/pull/12400","diff_url":"https://github.com/Microsoft/vscode/pull/12400.diff","patch_url":"https://github.com/Microsoft/vscode/pull/12400.patch","issue_url":"https://api.github.com/repos/Microsoft/vscode/issues/12400","number":12400,"state":"open","locked":false,"title":"Preserve files on exit (aka hot exit)","user":{"login":"Tyriar","id":2193314,"avatar_url":"https://avatars.githubusercontent.com/u/2193314?v=3","gravatar_id":"","url":"https://api.github.com/users/Tyriar","html_url":"https://github.com/Tyriar","followers_url":"https://api.github.com/users/Tyriar/followers","following_url":"https://api.github.com/users/Tyriar/following{/other_user}","gists_url":"https://api.github.com/users/Tyriar/gists{/gist_id}","starred_url":"https://api.github.com/users/Tyriar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tyriar/subscriptions","organizations_url":"https://api.github.com/users/Tyriar/orgs","repos_url":"https://api.github.com/users/Tyriar/repos","events_url":"https://api.github.com/users/Tyriar/events{/privacy}","received_events_url":"https://api.github.com/users/Tyriar/received_events","type":"User","site_admin":false},"body":"Opening this now to more easily track changes during development.\r\n\r\nFixes #101\r\n\r\n**TODO**\r\n\r\n- [x] Backup files that are modified\r\n- [x] Add a delay to file backup to reduce amount of disk access\r\n- [x] Discard backups when files are no longer dirty\r\n- [x] Ensure no collisions occur with backup files\r\n  - [x] Untitled files\r\n  - [x] Text files\r\n- [x] Discard backups when a window is being closed and there is another window open\r\n- [x] Retain backups when the last window is being exited\r\n  - [x] Ensure backups are up to date\r\n- [x] Restore backups if available on first window launch\r\n  - [x] Restore text files\r\n  - [x] Restore untitled files\r\n  - [x] Launch a second window if the backup folder is different to that requested\r\n\r\n**Clean up**\r\n\r\n- [ ] Resolve remaining TODOs\r\n- [ ] Remove any `console.log` statements\r\n- [ ] Add some tests","created_at":"2016-09-21T18:13:04Z","updated_at":"2016-10-13T14:54:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1c9c5376c1b503779668a3fbdfec9efd56d83457","assignee":{"login":"Tyriar","id":2193314,"avatar_url":"https://avatars.githubusercontent.com/u/2193314?v=3","gravatar_id":"","url":"https://api.github.com/users/Tyriar","html_url":"https://github.com/Tyriar","followers_url":"https://api.github.com/users/Tyriar/followers","following_url":"https://api.github.com/users/Tyriar/following{/other_user}","gists_url":"https://api.github.com/users/Tyriar/gists{/gist_id}","starred_url":"https://api.github.com/users/Tyriar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tyriar/subscriptions","organizations_url":"https://api.github.com/users/Tyriar/orgs","repos_url":"https://api.github.com/users/Tyriar/repos","events_url":"https://api.github.com/users/Tyriar/events{/privacy}","received_events_url":"https://api.github.com/users/Tyriar/received_events","type":"User","site_admin":false},"assignees":[{"login":"Tyriar","id":2193314,"avatar_url":"https://avatars.githubusercontent.com/u/2193314?v=3","gravatar_id":"","url":"https://api.github.com/users/Tyriar","html_url":"https://github.com/Tyriar","followers_url":"https://api.github.com/users/Tyriar/followers","following_url":"https://api.github.com/users/Tyriar/following{/other_user}","gists_url":"https://api.github.com/users/Tyriar/gists{/gist_id}","starred_url":"https://api.github.com/users/Tyriar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tyriar/subscriptions","organizations_url":"https://api.github.com/users/Tyriar/orgs","repos_url":"https://api.github.com/users/Tyriar/repos","events_url":"https://api.github.com/users/Tyriar/events{/privacy}","received_events_url":"https://api.github.com/users/Tyriar/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/Microsoft/vscode/milestones/29","html_url":"https://github.com/Microsoft/vscode/milestones/October%202016","labels_url":"https://api.github.com/repos/Microsoft/vscode/milestones/29/labels","id":2019000,"number":29,"title":"October 2016","description":null,"creator":{"login":"weinand","id":1898161,"avatar_url":"https://avatars.githubusercontent.com/u/1898161?v=3","gravatar_id":"","url":"https://api.github.com/users/weinand","html_url":"https://github.com/weinand","followers_url":"https://api.github.com/users/weinand/followers","following_url":"https://api.github.com/users/weinand/following{/other_user}","gists_url":"https://api.github.com/users/weinand/gists{/gist_id}","starred_url":"https://api.github.com/users/weinand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weinand/subscriptions","organizations_url":"https://api.github.com/users/weinand/orgs","repos_url":"https://api.github.com/users/weinand/repos","events_url":"https://api.github.com/users/weinand/events{/privacy}","received_events_url":"https://api.github.com/users/weinand/received_events","type":"User","site_admin":false},"open_issues":141,"closed_issues":115,"state":"open","created_at":"2016-09-21T11:16:13Z","updated_at":"2016-10-13T13:43:40Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/Microsoft/vscode/pulls/12400/commits","review_comments_url":"https://api.github.com/repos/Microsoft/vscode/pulls/12400/comments","review_comment_url":"https://api.github.com/repos/Microsoft/vscode/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/vscode/issues/12400/comments","statuses_url":"https://api.github.com/repos/Microsoft/vscode/statuses/550da5e2330dfd5480d2c462612fd1fbb433b4e2","head":{"label":"Microsoft:tyriar/101_hot_exit","ref":"tyriar/101_hot_exit","sha":"550da5e2330dfd5480d2c462612fd1fbb433b4e2","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":41881900,"name":"vscode","full_name":"Microsoft/vscode","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/vscode","description":"Visual Studio Code","fork":false,"url":"https://api.github.com/repos/Microsoft/vscode","forks_url":"https://api.github.com/repos/Microsoft/vscode/forks","keys_url":"https://api.github.com/repos/Microsoft/vscode/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/vscode/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/vscode/teams","hooks_url":"https://api.github.com/repos/Microsoft/vscode/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/vscode/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/vscode/events","assignees_url":"https://api.github.com/repos/Microsoft/vscode/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/vscode/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/vscode/tags","blobs_url":"https://api.github.com/repos/Microsoft/vscode/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/vscode/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/vscode/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/vscode/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/vscode/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/vscode/languages","stargazers_url":"https://api.github.com/repos/Microsoft/vscode/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/vscode/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/vscode/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/vscode/subscription","commits_url":"https://api.github.com/repos/Microsoft/vscode/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/vscode/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/vscode/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/vscode/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/vscode/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/vscode/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/vscode/merges","archive_url":"https://api.github.com/repos/Microsoft/vscode/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/vscode/downloads","issues_url":"https://api.github.com/repos/Microsoft/vscode/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/vscode/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/vscode/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/vscode/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/vscode/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/vscode/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/vscode/deployments","created_at":"2015-09-03T20:23:38Z","updated_at":"2016-10-13T14:08:11Z","pushed_at":"2016-10-13T14:53:32Z","git_url":"git://github.com/Microsoft/vscode.git","ssh_url":"git@github.com:Microsoft/vscode.git","clone_url":"https://github.com/Microsoft/vscode.git","svn_url":"https://github.com/Microsoft/vscode","homepage":"http://code.visualstudio.com","size":60134,"stargazers_count":18413,"watchers_count":18413,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2524,"mirror_url":null,"open_issues_count":2803,"forks":2524,"open_issues":2803,"watchers":18413,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"c18db474ba70cdd961020ce4040733dcdf25571a","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":41881900,"name":"vscode","full_name":"Microsoft/vscode","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/vscode","description":"Visual Studio Code","fork":false,"url":"https://api.github.com/repos/Microsoft/vscode","forks_url":"https://api.github.com/repos/Microsoft/vscode/forks","keys_url":"https://api.github.com/repos/Microsoft/vscode/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/vscode/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/vscode/teams","hooks_url":"https://api.github.com/repos/Microsoft/vscode/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/vscode/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/vscode/events","assignees_url":"https://api.github.com/repos/Microsoft/vscode/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/vscode/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/vscode/tags","blobs_url":"https://api.github.com/repos/Microsoft/vscode/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/vscode/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/vscode/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/vscode/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/vscode/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/vscode/languages","stargazers_url":"https://api.github.com/repos/Microsoft/vscode/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/vscode/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/vscode/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/vscode/subscription","commits_url":"https://api.github.com/repos/Microsoft/vscode/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/vscode/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/vscode/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/vscode/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/vscode/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/vscode/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/vscode/merges","archive_url":"https://api.github.com/repos/Microsoft/vscode/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/vscode/downloads","issues_url":"https://api.github.com/repos/Microsoft/vscode/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/vscode/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/vscode/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/vscode/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/vscode/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/vscode/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/vscode/deployments","created_at":"2015-09-03T20:23:38Z","updated_at":"2016-10-13T14:08:11Z","pushed_at":"2016-10-13T14:53:32Z","git_url":"git://github.com/Microsoft/vscode.git","ssh_url":"git@github.com:Microsoft/vscode.git","clone_url":"https://github.com/Microsoft/vscode.git","svn_url":"https://github.com/Microsoft/vscode","homepage":"http://code.visualstudio.com","size":60134,"stargazers_count":18413,"watchers_count":18413,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2524,"mirror_url":null,"open_issues_count":2803,"forks":2524,"open_issues":2803,"watchers":18413,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/vscode/pulls/12400"},"html":{"href":"https://github.com/Microsoft/vscode/pull/12400"},"issue":{"href":"https://api.github.com/repos/Microsoft/vscode/issues/12400"},"comments":{"href":"https://api.github.com/repos/Microsoft/vscode/issues/12400/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/vscode/pulls/12400/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/vscode/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/vscode/pulls/12400/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/vscode/statuses/550da5e2330dfd5480d2c462612fd1fbb433b4e2"}}}}
{"actor":{"display_login":"bpasero"}}