summaryrefslogtreecommitdiff
path: root/crates/vcs_data/src/data/vault/service.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-12 04:28:28 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-12 04:51:34 +0800
commitc5fb22694e95f12c24b8d8af76999be7aea3fcec (patch)
tree399d8a24ce491fb635f3d09f2123290fe784059e /crates/vcs_data/src/data/vault/service.rs
parent444754489aca0454eb54e15a49fb8a6db0b68a07 (diff)
Reorganize crate structure and move documentation files
Diffstat (limited to 'crates/vcs_data/src/data/vault/service.rs')
-rw-r--r--crates/vcs_data/src/data/vault/service.rs40
1 files changed, 0 insertions, 40 deletions
diff --git a/crates/vcs_data/src/data/vault/service.rs b/crates/vcs_data/src/data/vault/service.rs
deleted file mode 100644
index 3f59c30..0000000
--- a/crates/vcs_data/src/data/vault/service.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(())
- }
-}