From 329b526bfb21b335df82cd8d771dd178bff234cc Mon Sep 17 00:00:00 2001 From: ZhenYi <434836402@qq.com> Date: Thu, 16 Apr 2026 22:24:14 +0800 Subject: [PATCH] fix(git): add storage_path existence pre-check to run_fsck and run_gc Consistent with run_sync: fail fast before blocking the thread pool if the repo storage path does not exist on disk. --- libs/git/hook/pool/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/git/hook/pool/mod.rs b/libs/git/hook/pool/mod.rs index cb520fa..c7e513f 100644 --- a/libs/git/hook/pool/mod.rs +++ b/libs/git/hook/pool/mod.rs @@ -439,6 +439,12 @@ impl GitHookPool { .map_err(crate::GitError::from)? .ok_or_else(|| crate::GitError::NotFound(format!("repo {} not found", repo_id)))?; + if !std::path::Path::new(&repo.storage_path).exists() { + return Err(crate::GitError::NotFound(format!( + "storage path does not exist: {}", repo.storage_path + ))); + } + self.log_stream .info(&task.id, &task.repo_id, "running fsck") .await; @@ -471,6 +477,12 @@ impl GitHookPool { .map_err(crate::GitError::from)? .ok_or_else(|| crate::GitError::NotFound(format!("repo {} not found", repo_id)))?; + if !std::path::Path::new(&repo.storage_path).exists() { + return Err(crate::GitError::NotFound(format!( + "storage path does not exist: {}", repo.storage_path + ))); + } + self.log_stream .info(&task.id, &task.repo_id, "running gc") .await;