Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fsdvh committed Sep 26, 2024
1 parent b44497e commit 8fb7cb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
18 changes: 6 additions & 12 deletions object_store/src/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,19 +438,13 @@ impl AsyncWrite for BufWriter {
}
BufWriterState::Flush(f) => return f.poll_unpin(cx).map_err(std::io::Error::from),
BufWriterState::Write(x) => {
let upload = x.take().ok_or_else(|| {
std::io::Error::new(
ErrorKind::InvalidInput,
"Cannot shutdown a writer that has already been shut down",
if let Some(upload) = x.take() {
self.state = BufWriterState::Flush(
async move { upload.finish().await.map(|_| ()) }.boxed(),
)
})?;
self.state = BufWriterState::Flush(
async move {
upload.finish().await?;
Ok(())
}
.boxed(),
)
} else {
return Poll::Ready(Ok(()));
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions object_store/src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ impl WriteMultipart {
/// Flush final chunk, and await completion of all in-flight requests
pub async fn finish(mut self) -> Result<PutResult> {
if !self.buffer.is_empty() {
self.wait_for_capacity(0).await?;
let part = std::mem::take(&mut self.buffer);
self.put_part(part.into())
}
Expand Down

0 comments on commit 8fb7cb2

Please sign in to comment.