diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-19 01:40:38 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-19 01:40:38 +0800 |
| commit | 1e9c97c21f8a4e55420712b054895ff8b4f9a849 (patch) | |
| tree | c6bd37889deb54c024f974f368a9a7d654cad822 /rola-bucket/src/bucket/init.rs | |
| parent | e078163c7cdbbf226c18d3e3afa7268a2878e18b (diff) | |
Implement bucket bind CRUD operations and config loading, along with
CLI integration for listing, setting, and removing bucket bindings.
Diffstat (limited to 'rola-bucket/src/bucket/init.rs')
| -rw-r--r-- | rola-bucket/src/bucket/init.rs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/rola-bucket/src/bucket/init.rs b/rola-bucket/src/bucket/init.rs index 30bf0f4..6834009 100644 --- a/rola-bucket/src/bucket/init.rs +++ b/rola-bucket/src/bucket/init.rs @@ -1,16 +1,18 @@ -use std::path::{Path, PathBuf}; +use std::{ + fs, + path::{Path, PathBuf}, +}; use shared_constants::{ bucket::{ DIR_BUCKET_COMPRESSED_OBJ, DIR_BUCKET_DELTA, DIR_BUCKET_ID_REVS, DIR_BUCKET_ID_TAGS, - DIR_BUCKET_OBJ, + DIR_BUCKET_IDMAP, DIR_BUCKET_OBJ, }, common::FILE_BUCKET_ROOT_CONFIG, }; use space_system::SpaceError; -use tokio::fs; -pub(crate) async fn init_bucket_at(path: PathBuf) -> Result<(), SpaceError> { +pub(crate) fn init_bucket_at(path: PathBuf) -> Result<(), SpaceError> { let bucket_config_file = path.join(FILE_BUCKET_ROOT_CONFIG); // Check if directory is empty @@ -19,32 +21,29 @@ pub(crate) async fn init_bucket_at(path: PathBuf) -> Result<(), SpaceError> { return Err(SpaceError::RequireEmptyDirectory); } - write_config(&bucket_config_file).await?; - create_dirs(&path).await?; + write_config(&bucket_config_file)?; + create_dirs(&path)?; Ok(()) } -async fn write_config(bucket_config_file: &Path) -> Result<(), SpaceError> { - fs::write(bucket_config_file, include_str!("../../res/bucket.toml")) - .await - .map_err(SpaceError::Io) +fn write_config(bucket_config_file: &Path) -> Result<(), SpaceError> { + fs::write(bucket_config_file, include_str!("../../res/bucket.toml")).map_err(SpaceError::Io) } -async fn create_dirs(bucket_dir: &Path) -> Result<(), SpaceError> { +fn create_dirs(bucket_dir: &Path) -> Result<(), SpaceError> { let dirs = [ DIR_BUCKET_OBJ, DIR_BUCKET_COMPRESSED_OBJ, DIR_BUCKET_DELTA, DIR_BUCKET_ID_REVS, DIR_BUCKET_ID_TAGS, + DIR_BUCKET_IDMAP, ]; for dir in dirs { let full_path = bucket_dir.join(dir); - fs::create_dir_all(&full_path) - .await - .map_err(SpaceError::Io)?; + fs::create_dir_all(&full_path).map_err(SpaceError::Io)?; } Ok(()) |
