Skip to content

Commit 8979b35

Browse files
committedJan 30, 2024
Ensure headers are maintained when converting manifests
Signed-off-by: Ryan Bottriell <[email protected]>
1 parent a7ad71b commit 8979b35

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed
 

‎crates/spfs/src/graph/manifest.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ impl Manifest {
112112
}
113113

114114
iter_tree(self, self.root(), &mut root);
115-
tracking::Manifest::new(root)
115+
let mut manifest = tracking::Manifest::new(root);
116+
// ensure that the manifest will round-trip in the case of it
117+
// being converted back into this type
118+
manifest.set_header(self.header().to_owned());
119+
manifest
116120
}
117121

118122
pub(super) fn legacy_encode(&self, mut writer: &mut impl std::io::Write) -> Result<()> {

‎crates/spfs/src/graph/object.rs

+16
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,16 @@ impl std::fmt::Debug for Header {
539539
}
540540
}
541541

542+
impl std::borrow::ToOwned for Header {
543+
type Owned = HeaderBuf;
544+
545+
fn to_owned(&self) -> Self::Owned {
546+
let mut buf = HeaderBuf(Default::default());
547+
buf.0[..].clone_from_slice(&self.0);
548+
buf
549+
}
550+
}
551+
542552
impl std::ops::Deref for Header {
543553
type Target = [u8];
544554

@@ -638,6 +648,12 @@ impl std::ops::Deref for HeaderBuf {
638648
}
639649
}
640650

651+
impl std::borrow::Borrow<Header> for HeaderBuf {
652+
fn borrow(&self) -> &Header {
653+
self
654+
}
655+
}
656+
641657
impl AsRef<Header> for HeaderBuf {
642658
#[inline]
643659
fn as_ref(&self) -> &Header {

‎crates/spfs/src/tracking/manifest.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,12 @@ impl<T> Manifest<T> {
9090
}
9191
}
9292

93+
pub fn header(&self) -> &graph::object::Header {
94+
&self.header
95+
}
96+
9397
pub fn set_header(&mut self, mut header: graph::object::HeaderBuf) {
94-
// an different object kind would cause bugs and should never be allowed
98+
// a different object kind would cause bugs and should never be allowed
9599
header.set_object_kind(graph::ObjectKind::Manifest);
96100
self.header = header;
97101
}

‎crates/spk-build/src/build/binary.rs

+3
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,9 @@ fn split_manifest_by_component(
886886
let mut manifests = HashMap::with_capacity(components.len());
887887
for component in components.iter() {
888888
let mut component_manifest = spfs::tracking::Manifest::default();
889+
// ensure we are storing things with the same settings as the
890+
// original manifest that was generated by the build
891+
component_manifest.set_header(manifest.header().to_owned());
889892

890893
// identify all the file paths that we will replicate
891894
// first so that we can also identify necessary

0 commit comments

Comments
 (0)
Please sign in to comment.