From 05de2da565a32ab3b144f7b95860897a13c895f7 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 29 Oct 2025 15:25:05 +0800 Subject: Improve vault lock error message and formatting - Use clearer error message when vault is already locked - Fix code formatting for consistency - Remove unnecessary line breaks in error formatting --- crates/vcs_data/src/data/vault/service.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'crates/vcs_data/src') diff --git a/crates/vcs_data/src/data/vault/service.rs b/crates/vcs_data/src/data/vault/service.rs index 22e91d5..3f59c30 100644 --- a/crates/vcs_data/src/data/vault/service.rs +++ b/crates/vcs_data/src/data/vault/service.rs @@ -9,7 +9,7 @@ impl Vault { } /// Check if the current Vault is locked - pub fn is_locked(&self) -> bool { + pub fn is_locked(&self) -> bool { self.lock_file_path().exists() } @@ -19,10 +19,7 @@ impl Vault { return Err(std::io::Error::new( std::io::ErrorKind::AlreadyExists, format!( - "Vault is already locked at {}. \ - To unlock, please stop any running services. \ - If you are certain no services are running, \ - please delete this file", + "Vault is locked! This indicates a service is already running here.\nPlease stop other services or delete the lock file at the vault root directory: {}", self.lock_file_path().display() ), )); @@ -34,9 +31,10 @@ impl Vault { /// Unlock the current Vault pub fn unlock(&self) -> Result<(), std::io::Error> { if let Err(e) = std::fs::remove_file(self.lock_file_path()) - && e.kind() != std::io::ErrorKind::NotFound { - return Err(e); - } + && e.kind() != std::io::ErrorKind::NotFound + { + return Err(e); + } Ok(()) } } -- cgit