realising, that an extra msg_thread will be nececary
This commit is contained in:
@@ -5,6 +5,7 @@ use home::home_dir;
|
||||
|
||||
use mize::error::{IntoMizeResult, MizeError, MizeResult, MizeResultTrait};
|
||||
use mize::instance::Instance;
|
||||
use mize::item::IntoItemData;
|
||||
use mize::platform::os::config_from_cli_args;
|
||||
|
||||
|
||||
@@ -16,19 +17,12 @@ pub fn set(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
let id = sub_matches.get_one::<String>("id")
|
||||
.ok_or(MizeError::new().msg("No id Argument specified"))?;
|
||||
|
||||
let item = instance.get(id)?;
|
||||
let value = sub_matches.get_one::<String>("value")
|
||||
.ok_or(MizeError::new().msg("No value Argument specified"))?;
|
||||
|
||||
let recurse_count = sub_matches.get_count("recurse");
|
||||
instance.set(id, value.into_item_data())?;
|
||||
|
||||
println!("{}", item.as_data_full()?);
|
||||
return Ok(());
|
||||
instance.wait_for_updaater_thread()?;
|
||||
|
||||
if recurse_count > 0 {
|
||||
println!("{}", item.id());
|
||||
println!("{}", item.as_data_full()?);
|
||||
} else {
|
||||
println!("{}", item);
|
||||
};
|
||||
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -42,7 +42,9 @@ impl FileStore {
|
||||
}
|
||||
|
||||
// init the store
|
||||
fs::write(path.join("next_id"), "1");
|
||||
if !path.join("next_id").exists() {
|
||||
fs::write(path.join("next_id"), "1");
|
||||
}
|
||||
|
||||
Ok(FileStore { path: Path::new(&path).to_owned() })
|
||||
}
|
||||
@@ -110,6 +112,9 @@ impl Store for FileStore {
|
||||
fn get_value_data_full(&self, id: MizeId) -> MizeResult<ItemData> {
|
||||
let file_path = self.path.join("store").join(id.namespace_str()).join(id.store_part());
|
||||
println!("file_path: {:?}", file_path.display());
|
||||
if !file_path.exists() {
|
||||
return Ok(ItemData::empty());
|
||||
}
|
||||
let file = OpenOptions::new().read(true).open(file_path)?;
|
||||
|
||||
let cbor_value: CborValue = ciborium::from_reader(file)
|
||||
|
||||
@@ -164,6 +164,7 @@ fn cli_matches() -> clap::ArgMatches {
|
||||
Command::new("set")
|
||||
.aliases(["s"])
|
||||
.arg(Arg::new("id").help("The id or path to set"))
|
||||
.arg(Arg::new("value").help("The value to set the path to"))
|
||||
)
|
||||
.subcommand(
|
||||
Command::new("show")
|
||||
|
||||
@@ -10,7 +10,7 @@ use tracing::{info, warn};
|
||||
use crate::instance::connection::{ConnListener, Connection};
|
||||
use crate::instance::{self, Instance};
|
||||
use crate::error::{MizeError, MizeResult, IntoMizeResult};
|
||||
use crate::proto::MizeMessage;
|
||||
use crate::proto::{self, MizeMessage};
|
||||
|
||||
pub struct UnixListener {
|
||||
sock_path: PathBuf,
|
||||
@@ -140,6 +140,7 @@ fn unix_incomming(mut unix_read: OwnedReadHalf, mut instance: Instance, conn_id:
|
||||
}
|
||||
let msg = MizeMessage::new(value, conn_id);
|
||||
println!("unix incoming got msg: {}", msg);
|
||||
println!("op channel len: {}", instance.op_tx.len());
|
||||
instance.got_msg(msg);
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user