Fix bugs in verify v2 and in verify v1 slab construction
authorJakob Cornell <jakob+gpg@jcornell.net>
Mon, 21 Feb 2022 19:14:15 +0000 (13:14 -0600)
committerJakob Cornell <jakob+gpg@jcornell.net>
Mon, 21 Feb 2022 20:29:58 +0000 (14:29 -0600)
disk_jumble/src/disk_jumble/db.py
disk_jumble/src/disk_jumble/verify.py

index 5b7e2f87c0b989f6066e32e71177c72648c8d806..66e75627aba227d5e2d48fb109337b38225636b6 100644 (file)
@@ -14,7 +14,7 @@ class Slab:
        sectors: range
        entity_id: bytes
        entity_offset: int
-       crypt_key: bytes
+       crypt_key: Optional[bytes]
 
 
 @dataclass
@@ -114,8 +114,9 @@ class Wrapper:
                        cursor.execute(stmt, {"disk_id": disk_id, "sector_size": sector_size})
                        for (_, rows_iter) in itertools.groupby(cursor, lambda r: r[0]):
                                rows = list(rows_iter)
-                               [(slab_id, disk_id, sectors_pg, entity_id, entity_off, key)] = {r[:6] for r in rows}
+                               [(slab_id, disk_id, sectors_pg, entity_id, entity_off, key_mem)] = {r[:6] for r in rows}
                                sectors = range(sectors_pg.lower, sectors_pg.upper)
+                               key = None if key_mem is None else bytes(key_mem)
                                slab = Slab(slab_id, disk_id, sectors, bytes(entity_id), entity_off, key)
 
                                # `None' if no hasher match in outer join, otherwise earliest match
index 946627015f117783742ec43dce77c28821d0b0f7..684739d7ba6cbeb71a330912275ac99f60caa4e2 100644 (file)
@@ -266,7 +266,7 @@ def _gen_verify_results(conn, disk_id: int, disk_file: io.BufferedIOBase, read_s
                                                        - 1
                                                )
                                        ) as sector,
-                                       entity.length as entity_length
+                                       entity.length as entity_length,
                                        substring(hashes, generate_series(0, octet_length(hashes) / 32 - 1, 32), 32) as hash,
                                        crypt_key
                                from (