Skip to content

Commit

Permalink
feat: Include starting offset for GHAC upload Content-Range (#3163)
Browse files Browse the repository at this point in the history
  • Loading branch information
huonw authored Sep 23, 2023
1 parent 2160dd6 commit a2fab34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions core/src/services/ghac/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl Accessor for GhacBackend {

// Write only 1 byte to allow create.
let req = self
.ghac_upload(cache_id, 1, AsyncBody::Bytes(Bytes::from_static(&[0])))
.ghac_upload(cache_id, 0, 1, AsyncBody::Bytes(Bytes::from_static(&[0])))
.await?;

let resp = self.client.send(req).await?;
Expand Down Expand Up @@ -562,6 +562,7 @@ impl GhacBackend {
pub async fn ghac_upload(
&self,
cache_id: i64,
offset: u64,
size: u64,
body: AsyncBody,
) -> Result<Request<AsyncBody>> {
Expand All @@ -575,7 +576,7 @@ impl GhacBackend {
req = req.header(
CONTENT_RANGE,
BytesContentRange::default()
.with_range(0, size - 1)
.with_range(offset, offset + size - 1)
.to_header(),
);

Expand Down
3 changes: 2 additions & 1 deletion core/src/services/ghac/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ impl oio::Write for GhacWriter {
let backend = backend.take().expect("GhacWriter must be initialized");

let cache_id = self.cache_id;
let offset = self.size;
let size = bs.remaining();
let bs = bs.bytes(size);

let fut = async move {
let res = async {
let req = backend
.ghac_upload(cache_id, size as u64, AsyncBody::Bytes(bs))
.ghac_upload(cache_id, offset, size as u64, AsyncBody::Bytes(bs))
.await?;

let resp = backend.client.send(req).await?;
Expand Down

0 comments on commit a2fab34

Please sign in to comment.