lightweight com.atproto.sync.listReposByCollection
45
fork

Configure Feed

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

partly implement getting repo info

oops we haven't done ser/de yet

phil f1525435 4e828091

+19 -13
+1 -1
src/server/handler.rs
··· 119 119 ExtractXrpc(req): ExtractXrpc<GetRepoStatusRequest>, 120 120 ) -> Result<Json<GetRepoStatusOutput<'static>>, GetRepoStatusError> { 121 121 let (info, prev) = 122 - crate::storage::repo::get(&db, &req.did)?.ok_or(GetRepoStatusError::RepoNotFound)?; 122 + crate::storage::repo::get(&db, req.did.clone())?.ok_or(GetRepoStatusError::RepoNotFound)?; 123 123 124 124 Ok(Json(GetRepoStatusOutput { 125 125 did: req.did,
+2 -2
src/storage/keys.rs
··· 88 88 } 89 89 90 90 /// `"repo"\0<did>` — per-repo state entry. 91 - pub fn repo(did: &Did<'_>) -> Vec<u8> { 91 + pub fn repo(did: Did<'_>) -> Vec<u8> { 92 92 let d = did.as_str(); 93 93 let mut key = Vec::with_capacity(PREFIX_REPO.len() + 1 + d.len()); 94 94 key.extend_from_slice(PREFIX_REPO); ··· 98 98 } 99 99 100 100 /// `"repoPrev"\0<did>` — per-repo transient sync state (rev + prevData CID). 101 - pub fn repo_prev(did: &Did<'_>) -> Vec<u8> { 101 + pub fn repo_prev(did: Did<'_>) -> Vec<u8> { 102 102 let d = did.as_str(); 103 103 let mut key = Vec::with_capacity(PREFIX_REPO_PREV.len() + 1 + d.len()); 104 104 key.extend_from_slice(PREFIX_REPO_PREV);
+15 -9
src/storage/repo.rs
··· 1 1 //! Per-repo state storage. 2 2 3 - use jacquard_common::types::string::Cid; 4 - use jacquard_common::types::string::Did; 5 - use jacquard_common::types::tid::Tid; 3 + use fjall::Readable; 4 + use jacquard_common::types::{string::Cid, string::Did, tid::Tid}; 6 5 7 6 use crate::storage::{DbRef, error::StorageResult, keys}; 8 7 ··· 71 70 /// Retrieve both [`RepoInfo`] and [`RepoPrev`] for a `did`. 72 71 /// 73 72 /// `None` if the repo is not indexed. 74 - pub fn get(_db: &DbRef, _did: &Did<'_>) -> StorageResult<Option<(RepoInfo, Option<RepoPrev>)>> { 75 - todo!("deserialize RepoInfo from fjall value") 73 + pub fn get(db: &DbRef, did: Did<'_>) -> StorageResult<Option<(RepoInfo, Option<RepoPrev>)>> { 74 + let snapshot = db.database.snapshot(); 75 + Ok(snapshot 76 + .get(&db.ks, keys::repo(did.clone()))? 77 + .map(|info| { 78 + let prev = snapshot.get(&db.ks, keys::repo_prev(did))?; 79 + Ok((info, prev)) 80 + }) 81 + .transpose()?) 76 82 } 77 83 78 84 /// Write a [`RepoInfo`] for `did`. 79 - pub fn put_info(_db: &DbRef, _did: &Did<'_>, _record: &RepoInfo) -> StorageResult<()> { 85 + pub fn put_info(_db: &DbRef, _did: Did<'_>, _record: &RepoInfo) -> StorageResult<()> { 80 86 todo!("serialize RepoInfo and write to fjall") 81 87 } 82 88 ··· 90 96 } 91 97 92 98 /// Read the transient [`RepoPrev`] for `did`. 93 - pub fn get_prev(_db: &DbRef, _did: &Did<'_>) -> StorageResult<Option<RepoPrev>> { 99 + pub fn get_prev(_db: &DbRef, _did: Did<'_>) -> StorageResult<Option<RepoPrev>> { 94 100 todo!("deserialize RepoPrev") 95 101 } 96 102 97 103 /// Write the transient [`RepoPrev`] for `did`. 98 - pub fn put_prev(_db: &DbRef, _did: &Did<'_>, _prev: &RepoPrev) -> StorageResult<()> { 104 + pub fn put_prev(_db: &DbRef, _did: Did<'_>, _prev: &RepoPrev) -> StorageResult<()> { 99 105 todo!("serialize and write RepoPrev") 100 106 } 101 107 102 108 /// Delete the transient [`RepoPrev`] for `did`. 103 - pub fn delete_prev(db: &DbRef, did: &Did<'_>) -> StorageResult<()> { 109 + pub fn delete_prev(db: &DbRef, did: Did<'_>) -> StorageResult<()> { 104 110 let key = keys::repo_prev(did); 105 111 db.ks.remove(key)?; 106 112 Ok(())
+1 -1
src/storage/resync.rs
··· 30 30 } 31 31 32 32 /// Remove all queue entries for `did` (e.g., after a successful resync). 33 - pub fn remove_did(_db: &DbRef, _did: &Did<'_>) -> StorageResult<()> { 33 + pub fn remove_did(_db: &DbRef, _did: Did<'_>) -> StorageResult<()> { 34 34 todo!("scan resync partition and remove all entries matching did") 35 35 }