fix: Don't make generated files read-only

Don't make generated files read-only
This commit is contained in:
Markus Westerlind 2019-01-05 19:35:07 +01:00 committed by GitHub
commit 0c67bbed06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,7 +108,6 @@ fn process_file_into(
if let Some(parent) = rs_file.parent() { if let Some(parent) = rs_file.parent() {
try!(fs::create_dir_all(parent)); try!(fs::create_dir_all(parent));
} }
try!(make_read_only(&rs_file, false));
try!(remove_old_file(&rs_file)); try!(remove_old_file(&rs_file));
// Load the LALRPOP source text for this file: // Load the LALRPOP source text for this file:
@ -133,8 +132,6 @@ fn process_file_into(
try!(writeln!(output_file, "{}", try!(hash_file(&lalrpop_file)))); try!(writeln!(output_file, "{}", try!(hash_file(&lalrpop_file))));
try!(output_file.write_all(&buffer)); try!(output_file.write_all(&buffer));
} }
try!(make_read_only(&rs_file, true));
} }
Ok(()) Ok(())
} }
@ -173,17 +170,6 @@ fn needs_rebuild(lalrpop_file: &Path, rs_file: &Path) -> io::Result<bool> {
} }
} }
fn make_read_only(rs_file: &Path, ro: bool) -> io::Result<()> {
if rs_file.is_file() {
let rs_metadata = try!(fs::metadata(&rs_file));
let mut rs_permissions = rs_metadata.permissions();
rs_permissions.set_readonly(ro);
fs::set_permissions(&rs_file, rs_permissions)
} else {
Ok(())
}
}
fn lalrpop_files<P: AsRef<Path>>(root_dir: P) -> io::Result<Vec<PathBuf>> { fn lalrpop_files<P: AsRef<Path>>(root_dir: P) -> io::Result<Vec<PathBuf>> {
let mut result = vec![]; let mut result = vec![];
for entry in try!(fs::read_dir(root_dir)) { for entry in try!(fs::read_dir(root_dir)) {