added namespace

This commit is contained in:
Sebastian Moser
2024-06-13 08:53:45 +02:00
parent b0306d0e33
commit 8de465734c
4 changed files with 54 additions and 35 deletions

View File

@@ -59,7 +59,10 @@ impl Store for FileStore {
}
fn set(&self, id: MizeId, data: ItemData) -> MizeResult<()> {
let file = OpenOptions::new().write(true).create(true).open(self.path.join("store").join(id.store_part()))?;
let path = self.path.join("store").join(id.namespace_str()).join(id.store_part());
let file = OpenOptions::new().write(true).create(true).open(path)?;
ciborium::into_writer(data.cbor(), file)?;
Ok(())
}
@@ -73,7 +76,9 @@ impl Store for FileStore {
}
fn get_value_raw(&self, id: MizeId) -> MizeResult<Vec<u8>> {
let file = OpenOptions::new().read(true).create(true).open(self.path.join("store").join(id.store_part()))?;
let path = self.path.join("store").join(id.namespace_str()).join(id.store_part());
let file = OpenOptions::new().read(true).create(true).open(path)?;
let cbor_val: CborValue = ciborium::from_reader(file)
.mize_result_msg(format!("could not read file '{}' from FileStore", self.path.join("store").join(id.store_part()).display()))?;

View File

@@ -59,15 +59,14 @@ pub fn os_instance_init(instance: &mut Instance) -> MizeResult<()> {
};
////// if a config.store is set, upgrade to the filestore there
let store_path = instance.get("0/conifg/store")?.value_string()?;
let instance_path = instance.get("0/conifg/instance_path")?.value_string()?;
if store_path != "" {
let file_store = FileStore::new(store_path)?;
if instance_path != "" {
let file_store = FileStore::new(instance_path)?;
let new_instance = &mut instance.migrate_to_store(Box::new(file_store))?;
return Ok(());
}
return Ok(());
Ok(())
}
pub fn config_from_cli_args(matches: &ArgMatches) -> MizeResult<ItemData> {