diff --git a/arborist/cold_clone.py b/arborist/cold_clone.py index 3cd2c37..fbe17d4 100644 --- a/arborist/cold_clone.py +++ b/arborist/cold_clone.py @@ -185,8 +185,19 @@ def _strip_chunk_content_and_dump_blobs( f"WHERE chunk_id IN ({placeholders})", batch_ids, ).fetchall() + # SQLite type affinity: a `BLOB` column can come back as + # bytes / bytearray / memoryview, OR as `str` if the value + # was originally INSERTed as text. latin-1 preserves + # arbitrary byte values 1:1 (codepoints 0..255) so the + # hash check below still matches. + def _as_bytes(v): + if isinstance(v, (bytes, bytearray)): + return bytes(v) + if isinstance(v, memoryview): + return v.tobytes() + return v.encode("latin-1") triples = [ - (cid, lh, bytes(c)) for cid, lh, c in rows if c is not None + (cid, lh, _as_bytes(c)) for cid, lh, c in rows if c is not None ] with ThreadPoolExecutor(max_workers=upload_workers) as ex: for cid in ex.map(_upload, triples):