Surfaced during review of #70 (#49). Maintainability only, no behavior change.
crates/gl/src/clone.rs was already over 1000 lines before #70 (1154) and is now ~1665. The review deferred the cleanup to keep #70 focused; tracking it here.
Three seams, in rough priority:
-
Extract the Arweave discovery loop in recover_from_arweave into a standalone async fn discover_tx_refs(client, ag, slug) -> (Vec<TxRef>, /* incomplete */ bool). Beyond shrinking the function, this makes the pagination bounds (page cap, id cap, non-advancing-cursor guard) unit-testable directly. Today those paths only have integration coverage, and the degenerate-cursor test can't cleanly isolate "guard fired" from "mock exhausted" because the loop is inline and only reachable through a full mockito + git scaffold.
-
Deduplicate the blob-install logic. The git hash-object -w write plus the oid-match verify is duplicated almost verbatim between recover_encrypted_blobs and recover_from_arweave. Pull it into a private install_blob(dest_str, oid, plaintext) -> Result<bool>.
-
Move the Arweave types out. TxRef, TxPage, parse_tx_page, height_rank, merge_manifests, and the discovery loop are self-contained and could live in a sibling module (e.g. crates/gl/src/clone/arweave.rs).
Goal: behavior-preserving refactor that brings clone.rs back under ~1000 lines and makes the discovery bounds unit-testable. Existing tests stay green; no functional change.
Surfaced during review of #70 (#49). Maintainability only, no behavior change.
crates/gl/src/clone.rswas already over 1000 lines before #70 (1154) and is now ~1665. The review deferred the cleanup to keep #70 focused; tracking it here.Three seams, in rough priority:
Extract the Arweave discovery loop in
recover_from_arweaveinto a standaloneasync fn discover_tx_refs(client, ag, slug) -> (Vec<TxRef>, /* incomplete */ bool). Beyond shrinking the function, this makes the pagination bounds (page cap, id cap, non-advancing-cursor guard) unit-testable directly. Today those paths only have integration coverage, and the degenerate-cursor test can't cleanly isolate "guard fired" from "mock exhausted" because the loop is inline and only reachable through a full mockito + git scaffold.Deduplicate the blob-install logic. The
git hash-object -wwrite plus the oid-match verify is duplicated almost verbatim betweenrecover_encrypted_blobsandrecover_from_arweave. Pull it into a privateinstall_blob(dest_str, oid, plaintext) -> Result<bool>.Move the Arweave types out.
TxRef,TxPage,parse_tx_page,height_rank,merge_manifests, and the discovery loop are self-contained and could live in a sibling module (e.g.crates/gl/src/clone/arweave.rs).Goal: behavior-preserving refactor that brings
clone.rsback under ~1000 lines and makes the discovery bounds unit-testable. Existing tests stay green; no functional change.