From 442be73ad4fc76e8d536a41bd42ac180461639b6 Mon Sep 17 00:00:00 2001 From: Koei <205915319+Koei32@users.noreply.github.com> Date: Thu, 21 May 2026 23:39:56 +0530 Subject: [PATCH 1/2] fix: reclone on windows --- backend/src/git.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/backend/src/git.rs b/backend/src/git.rs index ea89eb1a..bfa01bbb 100644 --- a/backend/src/git.rs +++ b/backend/src/git.rs @@ -242,21 +242,32 @@ impl Interface { pub fn reclone(&self) -> Result<()> { // First clone a repo into `repo__tmp`, open that, swap out let repo_path = Path::new("./repo"); // TODO: Possibly implement this path into new config? - let tmp_path = Path::new("./repo__tmp"); + let tmp_repo_path = Path::new("./repo__tmp"); // if a reclone was attempted but failed, repo__tmp might still exist - if tmp_path.exists() { + if tmp_repo_path.exists() { warn!("A previous re-clone failed, stale data was found"); - remove_dir_all(tmp_path)?; + remove_dir_all(tmp_repo_path)?; } - let tmp_repo = Repository::clone(&self.repo_url, tmp_path)?; + // clone into tmp directory + Repository::clone(&self.repo_url, tmp_repo_path)?; + + // make a dummy repo and replace the one in the mutex with it + let dummy_repo = Repository::init("./dummy")?; let mut lock = self.repo.lock().unwrap(); - *lock = tmp_repo; + *lock = dummy_repo; + info!("Deleting the old repo and replacing it with the new one..."); fs::remove_dir_all(repo_path)?; - fs::rename(tmp_path, repo_path)?; - *lock = Repository::open(repo_path)?; + fs::rename(tmp_repo_path, repo_path)?; + + // now, replace the dummy in the mutex with the new clone + let new_repo = Repository::open(repo_path)?; + *lock = new_repo; + + // cleanup + fs::remove_dir_all("./dummy")?; drop(lock); Ok(()) } From 1d3c9b8e2874237fb24d5125317551f47906738a Mon Sep 17 00:00:00 2001 From: Koei32 <205915319+Koei32@users.noreply.github.com> Date: Fri, 22 May 2026 17:57:13 +0530 Subject: [PATCH 2/2] comments + success message --- backend/src/git.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/backend/src/git.rs b/backend/src/git.rs index bfa01bbb..3a33e5f7 100644 --- a/backend/src/git.rs +++ b/backend/src/git.rs @@ -240,35 +240,34 @@ impl Interface { /// Completely clone and open a new repository, deleting the old one. #[tracing::instrument(skip_all)] pub fn reclone(&self) -> Result<()> { - // First clone a repo into `repo__tmp`, open that, swap out let repo_path = Path::new("./repo"); // TODO: Possibly implement this path into new config? let tmp_repo_path = Path::new("./repo__tmp"); - // if a reclone was attempted but failed, repo__tmp might still exist + // If a reclone was attempted but failed, repo__tmp might still exist if tmp_repo_path.exists() { - warn!("A previous re-clone failed, stale data was found"); + warn!("A previous re-clone failed, removing stale data..."); remove_dir_all(tmp_repo_path)?; } - // clone into tmp directory + // Clone the repo into tmp directory Repository::clone(&self.repo_url, tmp_repo_path)?; - // make a dummy repo and replace the one in the mutex with it + // Make a dummy repo and replace the old repo in the mutex with it let dummy_repo = Repository::init("./dummy")?; let mut lock = self.repo.lock().unwrap(); *lock = dummy_repo; - info!("Deleting the old repo and replacing it with the new one..."); + debug!("Deleting the old repo and replacing it with the new one..."); fs::remove_dir_all(repo_path)?; fs::rename(tmp_repo_path, repo_path)?; - // now, replace the dummy in the mutex with the new clone + // Now, replace the dummy in the mutex with the new clone and cleanup let new_repo = Repository::open(repo_path)?; *lock = new_repo; - - // cleanup fs::remove_dir_all("./dummy")?; drop(lock); + + info!("Reclone completed successfully"); Ok(()) }