Add more missing `memoryview' to `bytes' conversions
authorJakob Cornell <jakob+gpg@jcornell.net>
Sat, 6 Nov 2021 02:15:27 +0000 (21:15 -0500)
committerJakob Cornell <jakob+gpg@jcornell.net>
Sat, 6 Nov 2021 02:15:27 +0000 (21:15 -0500)
src/disk_jumble/db.py

index 61bb2fd89f4e578ca0fad5ec7f6f6e3de9afe0b1..b9461deb63b21151e496fc857a13c03dd28ca216 100644 (file)
@@ -57,9 +57,10 @@ class Wrapper:
 
                        cursor.execute(stmt, (tracker_id,))
                        for row in cursor:
-                               (info_hash,) = row
+                               (info_hash_mem,) = row
+                               info_hash = bytes(info_hash_mem)
                                assert len(info_hash) == 20
-                               yield bytes(info_hash)
+                               yield info_hash
 
        def insert_swarm_info(self, tracker_id: int, infos: Iterable["disk_jumble.scrape.ScrapeInfo"]) -> None:
                stmt = """
@@ -128,7 +129,7 @@ class Wrapper:
                                rows = list(rows_iter)
                                [(slab_id, disk_id, sectors_pg, entity_id, entity_off, key)] = {r[:6] for r in rows}
                                sectors = range(sectors_pg.lower, sectors_pg.upper)
-                               slab = Slab(slab_id, disk_id, sectors, entity_id, entity_off, key)
+                               slab = Slab(slab_id, disk_id, sectors, bytes(entity_id), entity_off, key)
 
                                # `None' if no hasher match in outer join, otherwise earliest match
                                (*_, id_, seq, end_off, state) = min(rows, key = lambda r: r[-2])