refactor(tvix/store/pathinfo/signing_wrapper): remove clone
Construct the owned signature in a separate scope, so all borrows to the original PathInfo are already dropped again, and we can modify the PathInfo without having to clone it. Change-Id: I03e7390540c2cfe7a2c61850bdbe8a33d213a5d9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12663 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
parent
d52d889f2b
commit
849966d614
1 changed files with 17 additions and 9 deletions
|
@ -50,15 +50,23 @@ where
|
||||||
self.inner.get(digest).await
|
self.inner.get(digest).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn put(&self, path_info: PathInfo) -> Result<PathInfo, Error> {
|
async fn put(&self, mut path_info: PathInfo) -> Result<PathInfo, Error> {
|
||||||
let mut path_info = path_info.clone();
|
path_info.signatures.push({
|
||||||
let mut nar_info = path_info.to_narinfo();
|
let mut nar_info = path_info.to_narinfo();
|
||||||
|
nar_info.signatures.clear();
|
||||||
nar_info.add_signature(self.signing_key.as_ref());
|
nar_info.add_signature(self.signing_key.as_ref());
|
||||||
path_info.signatures = nar_info
|
|
||||||
|
let s = nar_info
|
||||||
.signatures
|
.signatures
|
||||||
.into_iter()
|
.pop()
|
||||||
.map(|s| Signature::<String>::new(s.name().to_string(), s.bytes().to_owned()))
|
.expect("Tvix bug: no signature after signing op");
|
||||||
.collect();
|
debug_assert!(
|
||||||
|
nar_info.signatures.is_empty(),
|
||||||
|
"Tvix bug: more than one signature appeared"
|
||||||
|
);
|
||||||
|
|
||||||
|
Signature::new(s.name().to_string(), *s.bytes())
|
||||||
|
});
|
||||||
self.inner.put(path_info).await
|
self.inner.put(path_info).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue