diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-10-29 15:25:05 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2025-10-29 15:25:05 +0800 |
| commit | 05de2da565a32ab3b144f7b95860897a13c895f7 (patch) | |
| tree | 28b1c259d49593e752d526f330454d5ea1a30a13 /crates | |
| parent | eb167d3792e6af987425508dc806595f6be1f79c (diff) | |
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
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/vcs_data/src/data/vault/service.rs | 14 |
1 files changed, 6 insertions, 8 deletions
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(()) } } |
