diff --git a/src/fs.rs b/src/fs.rs index 631c320..8f9066b 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -30,6 +30,7 @@ fn tid_to_timestamp(tid: &str) -> Option { pub struct PdsFs { repos: IndexMap>, inodes: IndexSet, + rt: tokio::runtime::Runtime, } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -112,6 +113,7 @@ where PdsFs { repos: Default::default(), inodes: IndexSet::from([PdsFsEntry::Zero, PdsFsEntry::Root]), + rt: tokio::runtime::Runtime::new().unwrap(), } } @@ -185,8 +187,8 @@ where let did = self.inodes[col.parent].unwrap_did(); let repo = &mut self.repos[did]; let key = format!("{}/{}", col.nsid, r.rkey); - let rt = tokio::runtime::Runtime::new().unwrap(); - let size = rt + let size = self + .rt .block_on(repo.get_raw::(&key)) .ok() .flatten() @@ -404,14 +406,13 @@ where _lock: Option, reply: fuser::ReplyData, ) { - let rt = tokio::runtime::Runtime::new().unwrap(); if let Some(PdsFsEntry::Record(r)) = self.inodes.get_index(ino as usize) { let col = self.inodes[r.parent].unwrap_collection(); let did = self.inodes[col.parent].unwrap_did(); let repo = &mut self.repos[did]; let key = format!("{}/{}", col.nsid, r.rkey); - if let Ok(Some(val)) = rt.block_on(repo.get_raw::(&key)) { + if let Ok(Some(val)) = self.rt.block_on(repo.get_raw::(&key)) { reply.data(&serde_json::to_string_pretty(&val).unwrap().as_bytes()[offset as usize..]); return; }