diff --git a/CHANGELOG.md b/CHANGELOG.md index d7e1a947..4fe1b64e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lapce-proxy/src/buffer.rs b/lapce-proxy/src/buffer.rs index e0d82f51..d86b5e8b 100644 --- a/lapce-proxy/src/buffer.rs +++ b/lapce-proxy/src/buffer.rs @@ -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(()) }