Maybe not what you want but I like that I can preview it
+6
-4
src/fs.rs
+6
-4
src/fs.rs
···
169
.block_on(repo.get_raw::<ipld_core::ipld::Ipld>(&key))
170
.ok()
171
.flatten()
172
-
.map_or(0, |v| serde_json::to_string(&v).unwrap().len())
173
as u64;
174
let blocks = ((size as u32 + BLKSIZE - 1) / BLKSIZE) as u64;
175
fuser::FileAttr {
···
290
.chain(self.inodes.iter().enumerate().filter_map(|(i, e)| {
291
if let PdsFsEntry::Record(record) = e {
292
if record.parent == ino as usize {
293
-
Some((i as u64, record.rkey.clone()))
294
} else {
295
None
296
}
···
352
}
353
}
354
Some(PdsFsEntry::Collection(_)) => {
355
let record = PdsFsEntry::Record(PdsFsRecord {
356
parent: parent as usize,
357
-
rkey: name.to_string_lossy().to_string(),
358
});
359
if let Some(ino) = self.inodes.get_index_of(&record) {
360
reply.entry(&TTL, &self.attr(ino as u64), 0);
···
385
let key = format!("{}/{}", col.nsid, r.rkey);
386
387
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..]);
389
return;
390
}
391
}
···
169
.block_on(repo.get_raw::<ipld_core::ipld::Ipld>(&key))
170
.ok()
171
.flatten()
172
+
.map_or(0, |v| serde_json::to_string_pretty(&v).unwrap().len())
173
as u64;
174
let blocks = ((size as u32 + BLKSIZE - 1) / BLKSIZE) as u64;
175
fuser::FileAttr {
···
290
.chain(self.inodes.iter().enumerate().filter_map(|(i, e)| {
291
if let PdsFsEntry::Record(record) = e {
292
if record.parent == ino as usize {
293
+
Some((i as u64, format!("{}.json", record.rkey)))
294
} else {
295
None
296
}
···
352
}
353
}
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();
357
let record = PdsFsEntry::Record(PdsFsRecord {
358
parent: parent as usize,
359
+
rkey,
360
});
361
if let Some(ino) = self.inodes.get_index_of(&record) {
362
reply.entry(&TTL, &self.attr(ino as u64), 0);
···
387
let key = format!("{}/{}", col.nsid, r.rkey);
388
389
if let Ok(Some(val)) = rt.block_on(repo.get_raw::<ipld_core::ipld::Ipld>(&key)) {
390
+
reply.data(&serde_json::to_string_pretty(&val).unwrap().as_bytes()[offset as usize..]);
391
return;
392
}
393
}