diff --git a/src/fs.rs b/src/fs.rs index a9a1524..631c320 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -190,7 +190,7 @@ where .block_on(repo.get_raw::(&key)) .ok() .flatten() - .map_or(0, |v| serde_json::to_string(&v).unwrap().len()) + .map_or(0, |v| serde_json::to_string_pretty(&v).unwrap().len()) as u64; let blocks = ((size as u32 + BLKSIZE - 1) / BLKSIZE) as u64; @@ -315,7 +315,7 @@ where .chain(self.inodes.iter().enumerate().filter_map(|(i, e)| { if let PdsFsEntry::Record(record) = e { if record.parent == ino as usize { - Some((i as u64, record.rkey.clone())) + Some((i as u64, format!("{}.json", record.rkey))) } else { None } @@ -377,9 +377,11 @@ where } } Some(PdsFsEntry::Collection(_)) => { + let name_str = name.to_string_lossy(); + let rkey = name_str.strip_suffix(".json").unwrap_or(&name_str).to_string(); let record = PdsFsEntry::Record(PdsFsRecord { parent: parent as usize, - rkey: name.to_string_lossy().to_string(), + rkey, }); if let Some(ino) = self.inodes.get_index_of(&record) { reply.entry(&TTL, &self.attr(ino as u64), 0); @@ -410,7 +412,7 @@ where let key = format!("{}/{}", col.nsid, r.rkey); if let Ok(Some(val)) = rt.block_on(repo.get_raw::(&key)) { - reply.data(&serde_json::to_string(&val).unwrap().as_bytes()[offset as usize..]); + reply.data(&serde_json::to_string_pretty(&val).unwrap().as_bytes()[offset as usize..]); return; } }