From c8430ef4b388b04dcb41b61f3aed2f640215fd45 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Sun, 9 May 2021 14:49:06 +0200 Subject: [PATCH] more preice places for where to apply --- asyncgit/src/sync/utils.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/asyncgit/src/sync/utils.rs b/asyncgit/src/sync/utils.rs index 25af94cf..6a7ed4f9 100644 --- a/asyncgit/src/sync/utils.rs +++ b/asyncgit/src/sync/utils.rs @@ -59,12 +59,7 @@ pub(crate) fn repo(repo_path: &str) -> Result { pub(crate) fn work_dir(repo: &Repository) -> Result { let path = repo.workdir().ok_or(Error::NoWorkDir)?; - //Note: only canonicalize on windows to support long paths - #[cfg(windows)] - return Ok(path.canonicalize()?); - - #[cfg(not(windows))] - return Ok(path.into()); + Ok(path.into()) } /// @@ -184,7 +179,13 @@ pub(crate) fn repo_write_file( file: &str, content: &str, ) -> Result<()> { - let dir = work_dir(repo)?.join(file); + let dir = work_dir(repo)?; + + //Note: only canonicalize on windows to support long paths + #[cfg(windows)] + let dir = dir.canonicalize()?; + + let dir = dir.join(file); let file_path = dir.to_str().ok_or_else(|| { Error::Generic(String::from("invalid file path")) })?;