Skip to content

Commit dbd0f92

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 dbd0f92

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

src/model_signing/_serialization/incremental.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,26 @@ 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+
if isinstance(
100+
existing_manifest._serialization_type, manifest._FileSerialization
101+
):
102+
# Copy from file-based serialization
103+
self._serialization_description = manifest._FileSerialization(
104+
existing_manifest._serialization_type._hash_type,
105+
existing_manifest._serialization_type._allow_symlinks,
106+
existing_manifest._serialization_type._ignore_paths,
107+
)
108+
self._is_blake3 = (
109+
existing_manifest._serialization_type._hash_type == "blake3"
110+
)
111+
else:
112+
# Fall back to creating new one for shard-based manifests
113+
hasher = file_hasher_factory(pathlib.Path())
114+
self._serialization_description = manifest._FileSerialization(
115+
hasher.digest_name, self._allow_symlinks, self._ignore_paths
116+
)
117+
self._is_blake3 = hasher.digest_name == "blake3"
104118

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

0 commit comments

Comments
 (0)