orlp commented on code in PR #633:
URL:
https://github.com/apache/arrow-rs-object-store/pull/633#discussion_r2795759681
##########
src/aws/client.rs:
##########
@@ -398,19 +400,40 @@ impl Request<'_> {
}
pub(crate) fn with_payload(mut self, payload: PutPayload) -> Self {
- if (!self.config.skip_signature && self.config.sign_payload)
- || self.config.checksum.is_some()
- {
+ let needs_sha256_for_signing = !self.config.skip_signature &&
self.config.sign_payload;
+ let needs_sha256_for_checksum = matches!(self.config.checksum,
Some(Checksum::SHA256));
+
+ let sha256_digest = if needs_sha256_for_signing ||
needs_sha256_for_checksum {
Review Comment:
An idea but rather than doing this whole check beforehand with an `Option`,
I think you can just do
```rust
use std::cell::LazyCell;
let sha256_digest = LazyCell::new(|| {
let mut sha256 = Context::new(&digest::SHA256);
for part in &payload {
sha256.update(part);
}
sha256.finish()
});
if !self.config.skip_signature && self.config.sign_payload {
self.payload_sha256 = *sha256_digest;
}
match self.config.checksum {
Some(Checksum::SHA256) => {
self.builder = self.builder.header(
SHA256_CHECKSUM,
BASE64_STANDARD.encode(*sha256_digest),
);
}
```
##########
src/aws/client.rs:
##########
@@ -43,6 +43,7 @@ use async_trait::async_trait;
use base64::Engine;
use base64::prelude::BASE64_STANDARD;
use bytes::{Buf, Bytes};
+use crc_fast;
Review Comment:
This `use` is... useless 😅
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]