mount an atproto PDS repository as a FUSE filesystem oppi.li/posts/mounting_the_atmosphere/

Render files as *.json #5

closed opened by danabra.mov targeting main

Maybe not what you want but I like that I can preview it

Labels

None yet.

Participants 2
AT URI
at://did:plc:fpruhuo22xkm5o7ttr2ktxdo/sh.tangled.repo.pull/3m33p335wsx22
+6 -4
Diff #0
+6 -4
src/fs.rs
··· 169 169 .block_on(repo.get_raw::<ipld_core::ipld::Ipld>(&key)) 170 170 .ok() 171 171 .flatten() 172 - .map_or(0, |v| serde_json::to_string(&v).unwrap().len()) 172 + .map_or(0, |v| serde_json::to_string_pretty(&v).unwrap().len()) 173 173 as u64; 174 174 let blocks = ((size as u32 + BLKSIZE - 1) / BLKSIZE) as u64; 175 175 fuser::FileAttr { ··· 290 290 .chain(self.inodes.iter().enumerate().filter_map(|(i, e)| { 291 291 if let PdsFsEntry::Record(record) = e { 292 292 if record.parent == ino as usize { 293 - Some((i as u64, record.rkey.clone())) 293 + Some((i as u64, format!("{}.json", record.rkey))) 294 294 } else { 295 295 None 296 296 } ··· 352 352 } 353 353 } 354 354 Some(PdsFsEntry::Collection(_)) => { 355 + let name_str = name.to_string_lossy(); 356 + let rkey = name_str.strip_suffix(".json").unwrap_or(&name_str).to_string(); 355 357 let record = PdsFsEntry::Record(PdsFsRecord { 356 358 parent: parent as usize, 357 - rkey: name.to_string_lossy().to_string(), 359 + rkey, 358 360 }); 359 361 if let Some(ino) = self.inodes.get_index_of(&record) { 360 362 reply.entry(&TTL, &self.attr(ino as u64), 0); ··· 385 387 let key = format!("{}/{}", col.nsid, r.rkey); 386 388 387 389 if let Ok(Some(val)) = rt.block_on(repo.get_raw::<ipld_core::ipld::Ipld>(&key)) { 388 - reply.data(&serde_json::to_string(&val).unwrap().as_bytes()[offset as usize..]); 390 + reply.data(&serde_json::to_string_pretty(&val).unwrap().as_bytes()[offset as usize..]); 389 391 return; 390 392 } 391 393 }

History

1 round 2 comments
sign up or login to add to the discussion
danabra.mov submitted #0
expand 2 comments

idk why it says merge conflicts detected. i just copy pasted this from git diff on top of main

the patch is missing a newline character i believe:

ฮป curl https://tangled.org/@oppi.li/pdsfs/pulls/5/round/0.patch | git apply
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2114    0  2114    0     0   6685      0 --:--:-- --:--:-- --:--:--  6689
error: corrupt patch at line 44
closed without merging