diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-03-21 16:37:51 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-03-21 16:37:51 +0800 |
| commit | c811c5818d21a67280ef9dd35ad40f6f5411daa5 (patch) | |
| tree | 46062311242da24771466ad99be26b530e83d497 /legacy_data/src/data/vault/lock_status.rs | |
| parent | 9a60751a901f568bdeb154c4115235d4f3a0f8b9 (diff) | |
Good Bye! Legacy JVCS
Diffstat (limited to 'legacy_data/src/data/vault/lock_status.rs')
| -rw-r--r-- | legacy_data/src/data/vault/lock_status.rs | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/legacy_data/src/data/vault/lock_status.rs b/legacy_data/src/data/vault/lock_status.rs deleted file mode 100644 index 3f59c30..0000000 --- a/legacy_data/src/data/vault/lock_status.rs +++ /dev/null @@ -1,40 +0,0 @@ -use std::path::PathBuf; - -use crate::{constants::SERVER_FILE_LOCKFILE, data::vault::Vault}; - -impl Vault { - /// Get the path of the lock file for the current Vault - pub fn lock_file_path(&self) -> PathBuf { - self.vault_path().join(SERVER_FILE_LOCKFILE) - } - - /// Check if the current Vault is locked - pub fn is_locked(&self) -> bool { - self.lock_file_path().exists() - } - - /// Lock the current Vault - pub fn lock(&self) -> Result<(), std::io::Error> { - if self.is_locked() { - return Err(std::io::Error::new( - std::io::ErrorKind::AlreadyExists, - format!( - "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() - ), - )); - } - std::fs::File::create(self.lock_file_path())?; - Ok(()) - } - - /// 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); - } - Ok(()) - } -} |
