Skip to content

Commit

Permalink
Make BufWriter abortable
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Mar 17, 2024
1 parent 521e918 commit b172a6e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions object_store/src/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,19 @@ impl BufWriter {
state: BufWriterState::Buffer(path, Vec::new()),
}
}

/// Abort this writer, cleaning up any partially uploaded state
///
/// # Panic
///
/// Panics if this writer has already been shutdown or aborted
pub async fn abort(&mut self) -> crate::Result<()> {
match &mut self.state {
BufWriterState::Buffer(_, _) | BufWriterState::Prepare(_) => Ok(()),
BufWriterState::Flush(_) => panic!("Already shut down"),
BufWriterState::Write(x) => x.take().unwrap().abort().await,
}
}
}

impl AsyncWrite for BufWriter {
Expand Down

0 comments on commit b172a6e

Please sign in to comment.