{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/vscode/issues/31733","repository_url":"https://api.github.com/repos/Microsoft/vscode","labels_url":"https://api.github.com/repos/Microsoft/vscode/issues/31733/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/vscode/issues/31733/comments","events_url":"https://api.github.com/repos/Microsoft/vscode/issues/31733/events","html_url":"https://github.com/Microsoft/vscode/pull/31733","id":246604142,"number":31733,"title":"Use r+ with truncation when saving existing files","user":{"login":"seishun","id":988441,"avatar_url":"https://avatars1.githubusercontent.com/u/988441?v=4","gravatar_id":"","url":"https://api.github.com/users/seishun","html_url":"https://github.com/seishun","followers_url":"https://api.github.com/users/seishun/followers","following_url":"https://api.github.com/users/seishun/following{/other_user}","gists_url":"https://api.github.com/users/seishun/gists{/gist_id}","starred_url":"https://api.github.com/users/seishun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seishun/subscriptions","organizations_url":"https://api.github.com/users/seishun/orgs","repos_url":"https://api.github.com/users/seishun/repos","events_url":"https://api.github.com/users/seishun/events{/privacy}","received_events_url":"https://api.github.com/users/seishun/received_events","type":"User","site_admin":false},"labels":[{"id":287229833,"url":"https://api.github.com/repos/Microsoft/vscode/labels/cla-signed","name":"cla-signed","color":"009800","default":false}],"state":"open","locked":false,"assignee":{"login":"bpasero","id":900690,"avatar_url":"https://avatars3.githubusercontent.com/u/900690?v=4","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},"assignees":[{"login":"bpasero","id":900690,"avatar_url":"https://avatars3.githubusercontent.com/u/900690?v=4","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}],"milestone":{"url":"https://api.github.com/repos/Microsoft/vscode/milestones/48","html_url":"https://github.com/Microsoft/vscode/milestone/48","labels_url":"https://api.github.com/repos/Microsoft/vscode/milestones/48/labels","id":2627693,"number":48,"title":"August 2017","description":"","creator":{"login":"egamma","id":172399,"avatar_url":"https://avatars1.githubusercontent.com/u/172399?v=4","gravatar_id":"","url":"https://api.github.com/users/egamma","html_url":"https://github.com/egamma","followers_url":"https://api.github.com/users/egamma/followers","following_url":"https://api.github.com/users/egamma/following{/other_user}","gists_url":"https://api.github.com/users/egamma/gists{/gist_id}","starred_url":"https://api.github.com/users/egamma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/egamma/subscriptions","organizations_url":"https://api.github.com/users/egamma/orgs","repos_url":"https://api.github.com/users/egamma/repos","events_url":"https://api.github.com/users/egamma/events{/privacy}","received_events_url":"https://api.github.com/users/egamma/received_events","type":"User","site_admin":false},"open_issues":201,"closed_issues":70,"state":"open","created_at":"2017-07-07T14:09:46Z","updated_at":"2017-08-13T12:12:26Z","due_on":"2017-08-31T07:00:00Z","closed_at":null},"comments":12,"created_at":"2017-07-30T19:35:55Z","updated_at":"2017-08-13T14:43:33Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Microsoft/vscode/pulls/31733","html_url":"https://github.com/Microsoft/vscode/pull/31733","diff_url":"https://github.com/Microsoft/vscode/pull/31733.diff","patch_url":"https://github.com/Microsoft/vscode/pull/31733.patch"},"body":"Fixes https://github.com/Microsoft/vscode/issues/931\r\n\r\nHere's how things got this way:\r\n\r\n1. Windows API requires the `FILE_ATTRIBUTE_HIDDEN` flag when calling [`CreateFile`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx) on a hidden file if `CREATE_ALWAYS` is specified.\r\n2. Microsoft C run-time library never uses this flag, consequently `fopen` in `w` mode fails on hidden files.\r\n3. libuv follows MS CRT's behavior on Windows and fails with `UV_EPERM` when `uv_fs_open` is called with `O_WRONLY|O_CREAT|O_TRUNC` (aka \"w\") on a hidden file.\r\n4. Node.js uses `uv_fs_open` to implement `fs.open` and thus fails with `EPERM` when trying to open a hidden file with `flags='w'`.\r\n5. Visual Studio Code opens the file with `flags='w'` when saving a file, which [fails on hidden files](https://github.com/Microsoft/vscode/issues/931). We've gone full circle.\r\n\r\nThis PR uses `r+` when opening existing files and truncates them. We can't do it just for hidden files since Node.js doesn't provide an API to query the hiddenness of a file. We also can't do it for all files since `r+` fails if the file doesn't exist."},"comment":{"url":"https://api.github.com/repos/Microsoft/vscode/issues/comments/322046256","html_url":"https://github.com/Microsoft/vscode/pull/31733#issuecomment-322046256","issue_url":"https://api.github.com/repos/Microsoft/vscode/issues/31733","id":322046256,"user":{"login":"seishun","id":988441,"avatar_url":"https://avatars1.githubusercontent.com/u/988441?v=4","gravatar_id":"","url":"https://api.github.com/users/seishun","html_url":"https://github.com/seishun","followers_url":"https://api.github.com/users/seishun/followers","following_url":"https://api.github.com/users/seishun/following{/other_user}","gists_url":"https://api.github.com/users/seishun/gists{/gist_id}","starred_url":"https://api.github.com/users/seishun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seishun/subscriptions","organizations_url":"https://api.github.com/users/seishun/orgs","repos_url":"https://api.github.com/users/seishun/repos","events_url":"https://api.github.com/users/seishun/events{/privacy}","received_events_url":"https://api.github.com/users/seishun/received_events","type":"User","site_admin":false},"created_at":"2017-08-13T14:43:33Z","updated_at":"2017-08-13T14:43:33Z","body":"I removed the argument since it defaults to 'utf8' anyway."}}
{"actor":{"display_login":"seishun"}}