Merge pull request #564 from panekj/fix-perms

fix: don't overwrite permissions
This commit is contained in:
Dongdong Zhou 2022-05-30 12:14:08 +01:00 committed by GitHub
commit 3d7bec2ab3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -65,6 +65,8 @@ pub fn save(&mut self, rev: u64) -> Result<()> {
for chunk in self.rope.iter_chunks(..self.rope.len()) { for chunk in self.rope.iter_chunks(..self.rope.len()) {
f.write_all(chunk.as_bytes())?; f.write_all(chunk.as_bytes())?;
} }
let perm = fs::metadata(&self.path)?.permissions();
fs::set_permissions(tmp_path, perm)?;
fs::rename(tmp_path, &self.path)?; fs::rename(tmp_path, &self.path)?;
self.mod_time = get_mod_time(&self.path); self.mod_time = get_mod_time(&self.path);
Ok(()) Ok(())