diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-10-27 17:50:35 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2025-10-27 17:50:35 +0800 |
| commit | 60219b20754dda7f560deb5e9e442d46e4636507 (patch) | |
| tree | afeff681f11313e20da1f104a8d6df979fc51b7f /crates/vcs_actions/src | |
| parent | 5212da62bb6d7b3e0eb8d9b2801cc8d1d7ef4ece (diff) | |
update: Add server lock behavior to vault lifecycle
Lock the vault before starting the server and unlock it during shutdown.
Diffstat (limited to 'crates/vcs_actions/src')
| -rw-r--r-- | crates/vcs_actions/src/connection/action_service.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/vcs_actions/src/connection/action_service.rs b/crates/vcs_actions/src/connection/action_service.rs index f76921e..a657408 100644 --- a/crates/vcs_actions/src/connection/action_service.rs +++ b/crates/vcs_actions/src/connection/action_service.rs @@ -31,6 +31,12 @@ pub async fn server_entry(vault_path: impl Into<PathBuf>) -> Result<(), TcpTarge // Initialize the vault let vault: Arc<Vault> = init_vault(vault_cfg, vault_path.into()).await?; + // Lock the vault + vault.lock().map_err(|e| { + error!("{}", e); + TcpTargetError::Locked(e.to_string()) + })?; + // Create ActionPool let action_pool: Arc<ActionPool> = Arc::new(server_action_pool()); @@ -38,6 +44,9 @@ pub async fn server_entry(vault_path: impl Into<PathBuf>) -> Result<(), TcpTarge let (_shutdown_rx, future) = build_server_future(vault.clone(), action_pool.clone(), listener); future.await?; // Start and block until shutdown + // Unlock the vault + vault.unlock()?; + Ok(()) } |
