Skip to content

Commit

Permalink
fix: ensure disk GUID's match in header
Browse files Browse the repository at this point in the history
primary and backup header must match. This ensure the backup uses the
primary's GUID and adds a test to check.

fixes #39
  • Loading branch information
swysocki committed Aug 2, 2022
1 parent 091b1e0 commit 5b7503f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gpt_image/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ def __init__(self, geometry: Geometry):
self._geometry = geometry
self.protective_mbr: ProtectiveMBR = ProtectiveMBR(self._geometry)
self.primary_header: Header = Header(self._geometry)
self.secondary_header: Header = Header(self._geometry, is_backup=True)
self.secondary_header: Header = Header(
self._geometry, guid=self.primary_header.disk_guid, is_backup=True
)
self.partitions: PartitionEntryArray = PartitionEntryArray(self._geometry)

def update(self) -> None:
Expand Down
1 change: 1 addition & 0 deletions tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def test_table_init(new_geometry):
table = Table(geo)
assert table.primary_header.backup is False
assert table.secondary_header.backup is True
assert table.primary_header.disk_guid == table.secondary_header.disk_guid


def test_checksum_partitions(new_geometry):
Expand Down

0 comments on commit 5b7503f

Please sign in to comment.