Fast and robust atproto CAR file processing in rust
14
fork

Configure Feed

Select the types of activity you want to include in your feed.

convert rkey to string early

phil ed8fe080 49a4b51d

+7 -6
-3
src/drive.rs
··· 24 24 Tripped(#[from] Trip), 25 25 #[error("Not finished walking, but no more blocks are available to continue")] 26 26 Dnf, 27 - #[error("Record Rkey was invalid (not utf-8)")] 28 - BadRkey, 29 27 } 30 28 31 29 type CarBlock<E> = Result<(Cid, Vec<u8>), E>; ··· 113 111 return Ok(None); 114 112 } 115 113 Step::Step { rkey, data } => { 116 - let rkey = String::from_utf8(rkey).map_err(|_| DriveError::BadRkey)?; 117 114 return Ok(Some((Rkey(rkey), data))); 118 115 } 119 116 }
+7 -3
src/walk.rs
··· 12 12 BadCommit(Box<dyn std::error::Error>), 13 13 #[error("Failed to compute an rkey due to invalid prefix_len")] 14 14 EntryPrefixOutOfbounds, 15 + #[error("RKey was not utf-8")] 16 + EntryRkeyNotUtf8(#[from] std::string::FromUtf8Error), 15 17 } 16 18 17 19 #[derive(Debug)] 18 20 pub enum Step { 19 21 Rest, 20 22 Finish, 21 - Step { rkey: Vec<u8>, data: Vec<u8> }, 23 + Step { rkey: String, data: Vec<u8> }, 22 24 } 23 25 24 26 #[derive(Debug, PartialEq)] 25 27 enum Need { 26 28 Node(Cid), 27 - Record { rkey: Vec<u8>, cid: Cid }, 29 + Record { rkey: String, cid: Cid }, 28 30 } 29 31 30 32 fn needs_from_node(node: Node) -> Result<Vec<Need>, Trip> { ··· 43 45 rkey.extend_from_slice(pre_checked); 44 46 rkey.extend_from_slice(&entry.keysuffix); 45 47 prefix = rkey.clone(); 48 + 49 + let rkey = String::from_utf8(rkey)?; 46 50 47 51 out.push(Need::Record { 48 52 rkey, ··· 112 116 log::trace!("record block not found, resting"); 113 117 return Ok(Step::Rest); 114 118 }; 115 - let rkey = rkey.to_vec(); 119 + let rkey = rkey.clone(); 116 120 let data = data.to_vec(); 117 121 118 122 // found node, make sure we pop it from the stack