Skip to content

Commit

Permalink
fix(init): avoid TOCTTOU bug on syntax CSS dir
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Jun 27, 2022
1 parent 658b82d commit e9f0d35
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/book/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ impl BookBuilder {
js.write_all(theme::JS)?;

let syntax_dir = cssdir.join("syntax");
if !syntax_dir.exists() {
fs::create_dir(&syntax_dir)?;
}
fs::create_dir_all(syntax_dir)?;

let mut highlight_css = File::create(syntax_dir.join("light.css"))?;
highlight_css.write_all(theme::SYNTAX_LIGHT_CSS)?;
Expand Down

0 comments on commit e9f0d35

Please sign in to comment.