diff --git a/src/state.rs b/src/state.rs index 5f90b3d3..4c36e6b4 100644 --- a/src/state.rs +++ b/src/state.rs @@ -170,7 +170,11 @@ async fn handle_request( }); }; - db.put(key, &payload.bytes)?; + db.put(key, &payload.bytes).map_err(|e| StateError::RocksDBError { + action: "SetState".into(), + error: e.to_string(), + })?; + (serde_json::to_vec(&StateResponse::SetState).unwrap(), None) } StateAction::GetState(process_id) => { @@ -643,20 +647,3 @@ fn make_error_message(our_name: String, km: &KernelMessage, error: StateError) - fn process_to_vec(process: ProcessId) -> Vec { process.to_string().as_bytes().to_vec() } - -impl From for VfsError { - fn from(err: std::io::Error) -> Self { - VfsError::IOError { - error: err.to_string(), - path: "".to_string(), - } // replace with appropriate VfsError variant and fields - } -} -impl From for StateError { - fn from(error: rocksdb::Error) -> Self { - StateError::RocksDBError { - action: "ass".into(), - error: error.to_string(), - } - } -} diff --git a/src/vfs.rs b/src/vfs.rs index 4f0a6dd6..361c6d35 100644 --- a/src/vfs.rs +++ b/src/vfs.rs @@ -506,6 +506,9 @@ async fn check_caps( package_id: PackageId, vfs_dir_path: String, ) -> Result<(), VfsError> { + let src_package_id = + PackageId::new(source.process.package(), source.process.publisher()); + let (send_cap_bool, recv_cap_bool) = tokio::sync::oneshot::channel(); match &request.action { VfsAction::CreateDir @@ -524,6 +527,9 @@ async fn check_caps( | VfsAction::Rename(_) | VfsAction::AddZip | VfsAction::SetLen(_) => { + if src_package_id == package_id { + return Ok(()); + } send_to_caps_oracle .send(CapMessage::Has { on: source.process.clone(), @@ -557,6 +563,9 @@ async fn check_caps( | VfsAction::Seek(_) | VfsAction::Hash | VfsAction::Len => { + if src_package_id == package_id { + return Ok(()); + } send_to_caps_oracle .send(CapMessage::Has { on: source.process.clone(), @@ -584,9 +593,6 @@ async fn check_caps( Ok(()) } VfsAction::CreateDrive => { - // TODO add helper to types.rs? - let src_package_id = - PackageId::new(source.process.package(), source.process.publisher()); if src_package_id != package_id { // might have root caps send_to_caps_oracle @@ -701,6 +707,16 @@ impl From> for VfsError { } } +impl From for VfsError { + fn from(err: std::io::Error) -> Self { + VfsError::IOError { + path: "".into(), + error: err.to_string(), + } + } +} + + impl std::fmt::Display for VfsAction { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self)