Skip to content

Commit e1a9768

Browse files
committed
Copy serialization description from existing manifest
Instead of creating a new serialization description from scratch, copy all parameters (hash_type, allow_symlinks, ignore_paths) from the existing manifest's serialization type. This ensures consistency across incremental updates by preserving the original manifest's serialization configuration.
1 parent da2c695 commit e1a9768

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

src/model_signing/_serialization/incremental.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,27 @@ def __init__(
9595
if isinstance(item, manifest._File):
9696
self._existing_items[item.path] = item
9797

98-
# Precompute serialization description
99-
hasher = file_hasher_factory(pathlib.Path())
100-
self._serialization_description = manifest._FileSerialization(
101-
hasher.digest_name, self._allow_symlinks, self._ignore_paths
102-
)
103-
self._is_blake3 = hasher.digest_name == "blake3"
98+
# Copy serialization description from existing manifest
99+
# (similar to C++ copy constructor)
100+
if isinstance(
101+
existing_manifest._serialization_type, manifest._FileSerialization
102+
):
103+
# Copy from file-based serialization
104+
self._serialization_description = manifest._FileSerialization(
105+
existing_manifest._serialization_type._hash_type,
106+
existing_manifest._serialization_type._allow_symlinks,
107+
existing_manifest._serialization_type._ignore_paths,
108+
)
109+
self._is_blake3 = (
110+
existing_manifest._serialization_type._hash_type == "blake3"
111+
)
112+
else:
113+
# Fall back to creating new one for shard-based manifests
114+
hasher = file_hasher_factory(pathlib.Path())
115+
self._serialization_description = manifest._FileSerialization(
116+
hasher.digest_name, self._allow_symlinks, self._ignore_paths
117+
)
118+
self._is_blake3 = hasher.digest_name == "blake3"
104119

105120
def set_allow_symlinks(self, allow_symlinks: bool) -> None:
106121
"""Set whether following symlinks is allowed."""

0 commit comments

Comments
 (0)