{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/30152","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/30152/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/30152/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/30152/events","html_url":"https://github.com/rust-lang/rust/pull/30152","id":119823969,"number":30152,"title":"Fix race condition in fs::create_dir_all","user":{"login":"droundy","id":137513,"avatar_url":"https://avatars.githubusercontent.com/u/137513?v=3","gravatar_id":"","url":"https://api.github.com/users/droundy","html_url":"https://github.com/droundy","followers_url":"https://api.github.com/users/droundy/followers","following_url":"https://api.github.com/users/droundy/following{/other_user}","gists_url":"https://api.github.com/users/droundy/gists{/gist_id}","starred_url":"https://api.github.com/users/droundy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/droundy/subscriptions","organizations_url":"https://api.github.com/users/droundy/orgs","repos_url":"https://api.github.com/users/droundy/repos","events_url":"https://api.github.com/users/droundy/events{/privacy}","received_events_url":"https://api.github.com/users/droundy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"brson","id":147214,"avatar_url":"https://avatars.githubusercontent.com/u/147214?v=3","gravatar_id":"","url":"https://api.github.com/users/brson","html_url":"https://github.com/brson","followers_url":"https://api.github.com/users/brson/followers","following_url":"https://api.github.com/users/brson/following{/other_user}","gists_url":"https://api.github.com/users/brson/gists{/gist_id}","starred_url":"https://api.github.com/users/brson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brson/subscriptions","organizations_url":"https://api.github.com/users/brson/orgs","repos_url":"https://api.github.com/users/brson/repos","events_url":"https://api.github.com/users/brson/events{/privacy}","received_events_url":"https://api.github.com/users/brson/received_events","type":"User","site_admin":false},"milestone":null,"comments":9,"created_at":"2015-12-01T22:35:07Z","updated_at":"2015-12-02T17:29:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/30152","html_url":"https://github.com/rust-lang/rust/pull/30152","diff_url":"https://github.com/rust-lang/rust/pull/30152.diff","patch_url":"https://github.com/rust-lang/rust/pull/30152.patch"},"body":"The code would crash if the directory was created after create_dir_all\r\nchecked whether the directory already existed.  This was contrary to\r\nthe documentation which claimed to create the directory if it doesn't\r\nexist, implying (but not stating) that there would not be a failure\r\ndue to the directory existing."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/161372570","html_url":"https://github.com/rust-lang/rust/pull/30152#issuecomment-161372570","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/30152","id":161372570,"user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"created_at":"2015-12-02T17:29:25Z","updated_at":"2015-12-02T17:29:25Z","body":"I don't think it's possible for `create_dir_all` to provide the guarantee that the directory exists when it returns, however, as some other thread could always delete it right after it was created. Along those lines I think that there's not much use in handling one race here but not others such as directories being deleted in the hierarchy while others are being created.\r\n\r\nOverall most `std::fs` functions try to have one system call and be somewhat transactional, but that can't always be guaranteed, so if there are two racing operations there must be external synchronization to work robustly."}}