mirror of https://github.com/lapce/lapce.git
fix: dont overwrite symlink (#2131)
This commit is contained in:
parent
7186c2750c
commit
eb4cde2f47
|
@ -34,6 +34,7 @@
|
|||
- [#2056](https://github.com/lapce/lapce/pull/2056): Fix default directory of remote session file picker
|
||||
- [#2072](https://github.com/lapce/lapce/pull/2072): Fix connection issues from Windows to lapce proxy
|
||||
- [#2069](https://github.com/lapce/lapce/pull/2045): Fix not finding git repositories in parent path
|
||||
- [#2131](https://github.com/lapce/lapce/pull/2131): Fix overwriting symlink
|
||||
|
||||
## 0.2.5
|
||||
|
||||
|
|
|
@ -54,20 +54,22 @@ pub fn save(&mut self, rev: u64) -> Result<()> {
|
|||
ext
|
||||
},
|
||||
);
|
||||
let tmp_path = &self.path.with_extension(tmp_extension);
|
||||
let path = self.path.canonicalize()?;
|
||||
let tmp_path = &path.with_extension(tmp_extension);
|
||||
|
||||
let mut f = File::create(tmp_path)?;
|
||||
for chunk in self.rope.iter_chunks(..self.rope.len()) {
|
||||
f.write_all(chunk.as_bytes())?;
|
||||
}
|
||||
|
||||
if let Ok(metadata) = fs::metadata(&self.path) {
|
||||
if let Ok(metadata) = fs::metadata(&path) {
|
||||
let perm = metadata.permissions();
|
||||
fs::set_permissions(tmp_path, perm)?;
|
||||
}
|
||||
|
||||
fs::rename(tmp_path, &self.path)?;
|
||||
self.mod_time = get_mod_time(&self.path);
|
||||
fs::rename(tmp_path, &path)?;
|
||||
self.mod_time = get_mod_time(&path);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue