{"action":"created","comment":{"url":"https://api.github.com/repos/iojs/io.js/pulls/comments/25982508","id":25982508,"diff_hunk":"@@ -1097,7 +1097,9 @@ function writeAll(fd, buffer, offset, length, position, callback) {\n       } else {\n         offset += written;\n         length -= written;\n-        position += written;\n+        if (position !== null) {","path":"lib/fs.js","position":5,"original_position":5,"commit_id":"9fc598b7c28e80a18e1eff106c2f6bfd0d4f3e20","original_commit_id":"9fc598b7c28e80a18e1eff106c2f6bfd0d4f3e20","user":{"login":"bnoordhuis","id":275871,"avatar_url":"https://avatars.githubusercontent.com/u/275871?v=3","gravatar_id":"","url":"https://api.github.com/users/bnoordhuis","html_url":"https://github.com/bnoordhuis","followers_url":"https://api.github.com/users/bnoordhuis/followers","following_url":"https://api.github.com/users/bnoordhuis/following{/other_user}","gists_url":"https://api.github.com/users/bnoordhuis/gists{/gist_id}","starred_url":"https://api.github.com/users/bnoordhuis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bnoordhuis/subscriptions","organizations_url":"https://api.github.com/users/bnoordhuis/orgs","repos_url":"https://api.github.com/users/bnoordhuis/repos","events_url":"https://api.github.com/users/bnoordhuis/events{/privacy}","received_events_url":"https://api.github.com/users/bnoordhuis/received_events","type":"User","site_admin":false},"body":"I think the check needs to be `if (typeof position === 'number') {`, else `undefined` or `false` will still trigger the bad behavior.  It's also the condition that the documentation for `fs.write()` mentions.","created_at":"2015-03-06T22:09:02Z","updated_at":"2015-03-06T22:09:02Z","html_url":"https://github.com/iojs/io.js/pull/1063#discussion_r25982508","pull_request_url":"https://api.github.com/repos/iojs/io.js/pulls/1063","_links":{"self":{"href":"https://api.github.com/repos/iojs/io.js/pulls/comments/25982508"},"html":{"href":"https://github.com/iojs/io.js/pull/1063#discussion_r25982508"},"pull_request":{"href":"https://api.github.com/repos/iojs/io.js/pulls/1063"}}},"pull_request":{"url":"https://api.github.com/repos/iojs/io.js/pulls/1063","id":30518757,"html_url":"https://github.com/iojs/io.js/pull/1063","diff_url":"https://github.com/iojs/io.js/pull/1063.diff","patch_url":"https://github.com/iojs/io.js/pull/1063.patch","issue_url":"https://api.github.com/repos/iojs/io.js/issues/1063","number":1063,"state":"open","locked":false,"title":"fs: fix partial write corruption in writeFile and writeFileSync","user":{"login":"olov","id":19247,"avatar_url":"https://avatars.githubusercontent.com/u/19247?v=3","gravatar_id":"","url":"https://api.github.com/users/olov","html_url":"https://github.com/olov","followers_url":"https://api.github.com/users/olov/followers","following_url":"https://api.github.com/users/olov/following{/other_user}","gists_url":"https://api.github.com/users/olov/gists{/gist_id}","starred_url":"https://api.github.com/users/olov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olov/subscriptions","organizations_url":"https://api.github.com/users/olov/orgs","repos_url":"https://api.github.com/users/olov/repos","events_url":"https://api.github.com/users/olov/events{/privacy}","received_events_url":"https://api.github.com/users/olov/received_events","type":"User","site_admin":false},"body":"1. writeFileSync bumps position incorrectly, causing it to\r\ndrift in iteration three and onwards.\r\n\r\n2. Append mode files will get corrupted in the middle if\r\nwriteFile or writeFileSync iterates multiple times, unless\r\nrunning on Linux. position starts out as null so first write is\r\nOK, but then position will refer to a location inside an\r\nexisting file, corrupting that data. Linux ignores position for\r\nappend mode files so it doesn't happen there.\r\n\r\nThis commit fixes these two related issues by bumping position\r\ncorrectly and by always using null as the position argument\r\nto write/writeSync for append mode files.\r\n\r\nfixes #1058 \r\ncc @piscisaureus ","created_at":"2015-03-05T00:17:46Z","updated_at":"2015-03-06T22:09:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"133114d054867ed877bbd624e2f35e21b1bb10ed","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/iojs/io.js/pulls/1063/commits","review_comments_url":"https://api.github.com/repos/iojs/io.js/pulls/1063/comments","review_comment_url":"https://api.github.com/repos/iojs/io.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/iojs/io.js/issues/1063/comments","statuses_url":"https://api.github.com/repos/iojs/io.js/statuses/9fc598b7c28e80a18e1eff106c2f6bfd0d4f3e20","head":{"label":"olov:v1.x","ref":"v1.x","sha":"9fc598b7c28e80a18e1eff106c2f6bfd0d4f3e20","user":{"login":"olov","id":19247,"avatar_url":"https://avatars.githubusercontent.com/u/19247?v=3","gravatar_id":"","url":"https://api.github.com/users/olov","html_url":"https://github.com/olov","followers_url":"https://api.github.com/users/olov/followers","following_url":"https://api.github.com/users/olov/following{/other_user}","gists_url":"https://api.github.com/users/olov/gists{/gist_id}","starred_url":"https://api.github.com/users/olov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olov/subscriptions","organizations_url":"https://api.github.com/users/olov/orgs","repos_url":"https://api.github.com/users/olov/repos","events_url":"https://api.github.com/users/olov/events{/privacy}","received_events_url":"https://api.github.com/users/olov/received_events","type":"User","site_admin":false},"repo":{"id":31685467,"name":"io.js","full_name":"olov/io.js","owner":{"login":"olov","id":19247,"avatar_url":"https://avatars.githubusercontent.com/u/19247?v=3","gravatar_id":"","url":"https://api.github.com/users/olov","html_url":"https://github.com/olov","followers_url":"https://api.github.com/users/olov/followers","following_url":"https://api.github.com/users/olov/following{/other_user}","gists_url":"https://api.github.com/users/olov/gists{/gist_id}","starred_url":"https://api.github.com/users/olov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olov/subscriptions","organizations_url":"https://api.github.com/users/olov/orgs","repos_url":"https://api.github.com/users/olov/repos","events_url":"https://api.github.com/users/olov/events{/privacy}","received_events_url":"https://api.github.com/users/olov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/olov/io.js","description":"A friendly fork of Node.js with an open governance model","fork":true,"url":"https://api.github.com/repos/olov/io.js","forks_url":"https://api.github.com/repos/olov/io.js/forks","keys_url":"https://api.github.com/repos/olov/io.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/olov/io.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/olov/io.js/teams","hooks_url":"https://api.github.com/repos/olov/io.js/hooks","issue_events_url":"https://api.github.com/repos/olov/io.js/issues/events{/number}","events_url":"https://api.github.com/repos/olov/io.js/events","assignees_url":"https://api.github.com/repos/olov/io.js/assignees{/user}","branches_url":"https://api.github.com/repos/olov/io.js/branches{/branch}","tags_url":"https://api.github.com/repos/olov/io.js/tags","blobs_url":"https://api.github.com/repos/olov/io.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/olov/io.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/olov/io.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/olov/io.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/olov/io.js/statuses/{sha}","languages_url":"https://api.github.com/repos/olov/io.js/languages","stargazers_url":"https://api.github.com/repos/olov/io.js/stargazers","contributors_url":"https://api.github.com/repos/olov/io.js/contributors","subscribers_url":"https://api.github.com/repos/olov/io.js/subscribers","subscription_url":"https://api.github.com/repos/olov/io.js/subscription","commits_url":"https://api.github.com/repos/olov/io.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/olov/io.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/olov/io.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/olov/io.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/olov/io.js/contents/{+path}","compare_url":"https://api.github.com/repos/olov/io.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/olov/io.js/merges","archive_url":"https://api.github.com/repos/olov/io.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/olov/io.js/downloads","issues_url":"https://api.github.com/repos/olov/io.js/issues{/number}","pulls_url":"https://api.github.com/repos/olov/io.js/pulls{/number}","milestones_url":"https://api.github.com/repos/olov/io.js/milestones{/number}","notifications_url":"https://api.github.com/repos/olov/io.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/olov/io.js/labels{/name}","releases_url":"https://api.github.com/repos/olov/io.js/releases{/id}","created_at":"2015-03-04T23:25:05Z","updated_at":"2015-03-05T00:14:23Z","pushed_at":"2015-03-05T00:14:23Z","git_url":"git://github.com/olov/io.js.git","ssh_url":"git@github.com:olov/io.js.git","clone_url":"https://github.com/olov/io.js.git","svn_url":"https://github.com/olov/io.js","homepage":"https://iojs.org","size":120129,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"v1.x"}},"base":{"label":"iojs:v1.x","ref":"v1.x","sha":"78581c8d902f2ed32712b342091d89016030e4ba","user":{"login":"iojs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/iojs","html_url":"https://github.com/iojs","followers_url":"https://api.github.com/users/iojs/followers","following_url":"https://api.github.com/users/iojs/following{/other_user}","gists_url":"https://api.github.com/users/iojs/gists{/gist_id}","starred_url":"https://api.github.com/users/iojs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iojs/subscriptions","organizations_url":"https://api.github.com/users/iojs/orgs","repos_url":"https://api.github.com/users/iojs/repos","events_url":"https://api.github.com/users/iojs/events{/privacy}","received_events_url":"https://api.github.com/users/iojs/received_events","type":"Organization","site_admin":false},"repo":{"id":27193779,"name":"io.js","full_name":"iojs/io.js","owner":{"login":"iojs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/iojs","html_url":"https://github.com/iojs","followers_url":"https://api.github.com/users/iojs/followers","following_url":"https://api.github.com/users/iojs/following{/other_user}","gists_url":"https://api.github.com/users/iojs/gists{/gist_id}","starred_url":"https://api.github.com/users/iojs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iojs/subscriptions","organizations_url":"https://api.github.com/users/iojs/orgs","repos_url":"https://api.github.com/users/iojs/repos","events_url":"https://api.github.com/users/iojs/events{/privacy}","received_events_url":"https://api.github.com/users/iojs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/iojs/io.js","description":"A friendly fork of Node.js with an open governance model","fork":false,"url":"https://api.github.com/repos/iojs/io.js","forks_url":"https://api.github.com/repos/iojs/io.js/forks","keys_url":"https://api.github.com/repos/iojs/io.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iojs/io.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iojs/io.js/teams","hooks_url":"https://api.github.com/repos/iojs/io.js/hooks","issue_events_url":"https://api.github.com/repos/iojs/io.js/issues/events{/number}","events_url":"https://api.github.com/repos/iojs/io.js/events","assignees_url":"https://api.github.com/repos/iojs/io.js/assignees{/user}","branches_url":"https://api.github.com/repos/iojs/io.js/branches{/branch}","tags_url":"https://api.github.com/repos/iojs/io.js/tags","blobs_url":"https://api.github.com/repos/iojs/io.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iojs/io.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iojs/io.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/iojs/io.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iojs/io.js/statuses/{sha}","languages_url":"https://api.github.com/repos/iojs/io.js/languages","stargazers_url":"https://api.github.com/repos/iojs/io.js/stargazers","contributors_url":"https://api.github.com/repos/iojs/io.js/contributors","subscribers_url":"https://api.github.com/repos/iojs/io.js/subscribers","subscription_url":"https://api.github.com/repos/iojs/io.js/subscription","commits_url":"https://api.github.com/repos/iojs/io.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/iojs/io.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/iojs/io.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/iojs/io.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/iojs/io.js/contents/{+path}","compare_url":"https://api.github.com/repos/iojs/io.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iojs/io.js/merges","archive_url":"https://api.github.com/repos/iojs/io.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iojs/io.js/downloads","issues_url":"https://api.github.com/repos/iojs/io.js/issues{/number}","pulls_url":"https://api.github.com/repos/iojs/io.js/pulls{/number}","milestones_url":"https://api.github.com/repos/iojs/io.js/milestones{/number}","notifications_url":"https://api.github.com/repos/iojs/io.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iojs/io.js/labels{/name}","releases_url":"https://api.github.com/repos/iojs/io.js/releases{/id}","created_at":"2014-11-26T19:57:11Z","updated_at":"2015-03-06T22:04:30Z","pushed_at":"2015-03-06T22:04:30Z","git_url":"git://github.com/iojs/io.js.git","ssh_url":"git@github.com:iojs/io.js.git","clone_url":"https://github.com/iojs/io.js.git","svn_url":"https://github.com/iojs/io.js","homepage":"https://iojs.org","size":154241,"stargazers_count":10900,"watchers_count":10900,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":696,"mirror_url":null,"open_issues_count":183,"forks":696,"open_issues":183,"watchers":10900,"default_branch":"v1.x"}},"_links":{"self":{"href":"https://api.github.com/repos/iojs/io.js/pulls/1063"},"html":{"href":"https://github.com/iojs/io.js/pull/1063"},"issue":{"href":"https://api.github.com/repos/iojs/io.js/issues/1063"},"comments":{"href":"https://api.github.com/repos/iojs/io.js/issues/1063/comments"},"review_comments":{"href":"https://api.github.com/repos/iojs/io.js/pulls/1063/comments"},"review_comment":{"href":"https://api.github.com/repos/iojs/io.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/iojs/io.js/pulls/1063/commits"},"statuses":{"href":"https://api.github.com/repos/iojs/io.js/statuses/9fc598b7c28e80a18e1eff106c2f6bfd0d4f3e20"}}}}