Skip to content

Commit 5442241

Browse files
authored
Merge branch 'main' into main
2 parents ebc53e1 + bc4eccd commit 5442241

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0),
66

77
## Unreleased
88

9+
## [0.4.19](https://github.com/Nullus157/async-compression/compare/v0.4.18...v0.4.19) - 2025-02-27
10+
11+
### Changed
12+
13+
- Update `bzip2` dependency to `0.5`.
14+
15+
### Fixed
16+
17+
- Ensure that flush finishes before continuing.
18+
919
## [0.4.18](https://github.com/Nullus157/async-compression/compare/v0.4.17...v0.4.18) - 2024-11-23
1020

1121
### Fixed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "async-compression"
3-
version = "0.4.18"
3+
version = "0.4.19"
44
authors = ["Wim Looman <[email protected]>", "Allen Bui <[email protected]>"]
55
edition = "2018"
66
resolver = "2"

src/tokio/write/generic/encoder.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use tokio::io::{AsyncBufRead, AsyncRead, AsyncWrite, ReadBuf};
1616
#[derive(Debug)]
1717
enum State {
1818
Encoding,
19+
Flushing,
1920
Finishing,
2021
Done,
2122
}
@@ -80,6 +81,12 @@ impl<W: AsyncWrite, E: Encode> Encoder<W, E> {
8081
State::Encoding
8182
}
8283

84+
// Once a flush has been started, it must be completed.
85+
State::Flushing => match this.encoder.flush(&mut output)? {
86+
true => State::Encoding,
87+
false => State::Flushing,
88+
},
89+
8390
State::Finishing | State::Done => {
8491
return Poll::Ready(Err(io::Error::new(
8592
io::ErrorKind::Other,
@@ -105,7 +112,7 @@ impl<W: AsyncWrite, E: Encode> Encoder<W, E> {
105112
let mut output = PartialBuffer::new(output);
106113

107114
let done = match this.state {
108-
State::Encoding => this.encoder.flush(&mut output)?,
115+
State::Encoding | State::Flushing => this.encoder.flush(&mut output)?,
109116

110117
State::Finishing | State::Done => {
111118
return Poll::Ready(Err(io::Error::new(
@@ -114,11 +121,13 @@ impl<W: AsyncWrite, E: Encode> Encoder<W, E> {
114121
)))
115122
}
116123
};
124+
*this.state = State::Flushing;
117125

118126
let produced = output.written().len();
119127
this.writer.as_mut().produce(produced);
120128

121129
if done {
130+
*this.state = State::Encoding;
122131
return Poll::Ready(Ok(()));
123132
}
124133
}
@@ -140,6 +149,12 @@ impl<W: AsyncWrite, E: Encode> Encoder<W, E> {
140149
}
141150
}
142151

152+
// Once a flush has been started, it must be completed.
153+
State::Flushing => match this.encoder.flush(&mut output)? {
154+
true => State::Finishing,
155+
false => State::Flushing,
156+
},
157+
143158
State::Done => State::Done,
144159
};
145160

0 commit comments

Comments
 (0)