summaryrefslogtreecommitdiff
path: root/rola-bucket/src/bucket/init.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-06-19 23:42:19 +0800
committer魏曹先生 <1992414357@qq.com>2026-06-19 23:42:19 +0800
commit40183e431da97fe0377b2f2e2ea47b3a14376680 (patch)
tree0c117e2ec707f3ad33206f1e320af2b439f80dbe /rola-bucket/src/bucket/init.rs
parentd36acf196f7475a91550cc64c9c9a545adb65c50 (diff)
feat(rola-bucket): add TOML bucket config read/write
Add functions to read and write BucketConfig from and to TOML files, including space-aware variants. Replace hardcoded resource file with serializable config struct.
Diffstat (limited to 'rola-bucket/src/bucket/init.rs')
-rw-r--r--rola-bucket/src/bucket/init.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/rola-bucket/src/bucket/init.rs b/rola-bucket/src/bucket/init.rs
index 6834009..d2dda24 100644
--- a/rola-bucket/src/bucket/init.rs
+++ b/rola-bucket/src/bucket/init.rs
@@ -12,6 +12,8 @@ use shared_constants::{
};
use space_system::SpaceError;
+use crate::config::{BucketConfig, write_bucket_config_to_path};
+
pub(crate) fn init_bucket_at(path: PathBuf) -> Result<(), SpaceError> {
let bucket_config_file = path.join(FILE_BUCKET_ROOT_CONFIG);
@@ -21,16 +23,12 @@ pub(crate) fn init_bucket_at(path: PathBuf) -> Result<(), SpaceError> {
return Err(SpaceError::RequireEmptyDirectory);
}
- write_config(&bucket_config_file)?;
+ write_bucket_config_to_path(&bucket_config_file, &BucketConfig::default())?;
create_dirs(&path)?;
Ok(())
}
-fn write_config(bucket_config_file: &Path) -> Result<(), SpaceError> {
- fs::write(bucket_config_file, include_str!("../../res/bucket.toml")).map_err(SpaceError::Io)
-}
-
fn create_dirs(bucket_dir: &Path) -> Result<(), SpaceError> {
let dirs = [
DIR_BUCKET_OBJ,