Skip to content

Commit

Permalink
fix(services/gcs): checked_rem_euclid could return Some(0) (apache#2220)
Browse files Browse the repository at this point in the history
* fix: checked_rem_euclid could return Some(0)

Signed-off-by: Xuanwo <[email protected]>

* Add error context

Signed-off-by: Xuanwo <[email protected]>

---------

Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored and suyanhanx committed May 8, 2023
1 parent 9543da2 commit 36bb249
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/src/services/gcs/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,14 @@ impl Builder for GcsBuilder {
let signer = GoogleSigner::new("storage");

let write_fixed_size = self.write_fixed_size.unwrap_or(DEFAULT_WRITE_FIXED_SIZE);
if write_fixed_size.checked_rem_euclid(256 * 1024).is_some() {
// GCS requires write must align with 256 KiB.
if write_fixed_size % (256 * 1024) != 0 {
return Err(Error::new(
ErrorKind::ConfigInvalid,
"The write fixed buffer size is misconfigured",
)
.with_context("service", Scheme::Gcs));
.with_context("service", Scheme::Gcs)
.with_context("write_fixed_size", write_fixed_size.to_string()));
}

let backend = GcsBackend {
Expand Down

0 comments on commit 36bb249

Please sign in to comment.