mount an atproto PDS repository as a FUSE filesystem

initialize tokio once

authored by danabra.mov and committed by Tangled 6831868c 83bfa444

Changed files
+5 -4
src
+5 -4
src/fs.rs
··· 30 30 pub struct PdsFs<R> { 31 31 repos: IndexMap<String, Repository<R>>, 32 32 inodes: IndexSet<PdsFsEntry>, 33 + rt: tokio::runtime::Runtime, 33 34 } 34 35 35 36 #[derive(Debug, Clone, PartialEq, Eq, Hash)] ··· 112 113 PdsFs { 113 114 repos: Default::default(), 114 115 inodes: IndexSet::from([PdsFsEntry::Zero, PdsFsEntry::Root]), 116 + rt: tokio::runtime::Runtime::new().unwrap(), 115 117 } 116 118 } 117 119 ··· 185 187 let did = self.inodes[col.parent].unwrap_did(); 186 188 let repo = &mut self.repos[did]; 187 189 let key = format!("{}/{}", col.nsid, r.rkey); 188 - let rt = tokio::runtime::Runtime::new().unwrap(); 189 - let size = rt 190 + let size = self 191 + .rt 190 192 .block_on(repo.get_raw::<ipld_core::ipld::Ipld>(&key)) 191 193 .ok() 192 194 .flatten() ··· 404 406 _lock: Option<u64>, 405 407 reply: fuser::ReplyData, 406 408 ) { 407 - let rt = tokio::runtime::Runtime::new().unwrap(); 408 409 if let Some(PdsFsEntry::Record(r)) = self.inodes.get_index(ino as usize) { 409 410 let col = self.inodes[r.parent].unwrap_collection(); 410 411 let did = self.inodes[col.parent].unwrap_did(); 411 412 let repo = &mut self.repos[did]; 412 413 let key = format!("{}/{}", col.nsid, r.rkey); 413 414 414 - if let Ok(Some(val)) = rt.block_on(repo.get_raw::<ipld_core::ipld::Ipld>(&key)) { 415 + if let Ok(Some(val)) = self.rt.block_on(repo.get_raw::<ipld_core::ipld::Ipld>(&key)) { 415 416 reply.data(&serde_json::to_string_pretty(&val).unwrap().as_bytes()[offset as usize..]); 416 417 return; 417 418 }