Skip to content

Commit fc85156

Browse files
authored
GrpcStore now sends digest function from context (#1587)
GrpcStore will now properly send the digest function over Grpc from the origin context. Previously this had to be set in the config.
1 parent 44d8db1 commit fc85156

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

nativelink-store/src/grpc_store.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,18 @@ impl StoreDriver for GrpcStore {
584584
return self.update_action_result_from_bytes(digest, reader).await;
585585
}
586586

587+
let digest_function = ActiveOriginContext::get_value(&ACTIVE_HASHER_FUNC)
588+
.err_tip(|| "In GrpcStore::update()")?
589+
.map_or_else(default_digest_hasher_func, |v| *v)
590+
.proto_digest_func()
591+
.as_str_name()
592+
.to_ascii_lowercase();
587593
let mut buf = Uuid::encode_buffer();
588594
let resource_name = format!(
589-
"{}/uploads/{}/blobs/{}/{}",
595+
"{}/uploads/{}/blobs/{}/{}/{}",
590596
&self.instance_name,
591597
Uuid::new_v4().hyphenated().encode_lower(&mut buf),
598+
digest_function,
592599
digest.packed_hash(),
593600
digest.size_bytes(),
594601
);
@@ -675,10 +682,16 @@ impl StoreDriver for GrpcStore {
675682
if digest.size_bytes() == 0 {
676683
return writer.send_eof();
677684
}
678-
685+
let digest_function = ActiveOriginContext::get_value(&ACTIVE_HASHER_FUNC)
686+
.err_tip(|| "In GrpcStore::update()")?
687+
.map_or_else(default_digest_hasher_func, |v| *v)
688+
.proto_digest_func()
689+
.as_str_name()
690+
.to_ascii_lowercase();
679691
let resource_name = format!(
680-
"{}/blobs/{}/{}",
692+
"{}/blobs/{}/{}/{}",
681693
&self.instance_name,
694+
digest_function,
682695
digest.packed_hash(),
683696
digest.size_bytes(),
684697
);

0 commit comments

Comments
 (0)