@@ -26,7 +26,6 @@ pub(crate) enum Compressor {
26
26
Zstd ( ZstdEncoder ) ,
27
27
}
28
28
29
- //FIXME: we should call finish at the end
30
29
impl Compressor {
31
30
pub ( crate ) fn new < ' a , It : ' a > ( it : It ) -> Option < Self >
32
31
where
@@ -89,13 +88,14 @@ where {
89
88
partial_output. advance ( written) ;
90
89
91
90
match self . encode ( & mut partial_input, & mut partial_output) {
92
- Err ( e) => panic ! ( "{e:?}" ) ,
91
+ Err ( e) => {
92
+ let _ = tx. send ( Err ( e. into ( ) ) ) . await ;
93
+ return ;
94
+ }
93
95
Ok ( ( ) ) => { }
94
96
}
95
97
96
- //let read = partial_input.written().len();
97
98
written += partial_output. written ( ) . len ( ) ;
98
- //println!("encode: read from input: {read}, written = {written}");
99
99
100
100
if !partial_input. unwritten ( ) . is_empty ( ) {
101
101
// there was not enough space in the output buffer to compress everything,
@@ -105,12 +105,13 @@ where {
105
105
buf. reserve ( written) ;
106
106
}
107
107
} else {
108
- // FIXME: what happens if we try to flush in a full buffer
109
108
match self . flush ( & mut partial_output) {
110
- Err ( e) => panic ! ( "{e:?}" ) ,
109
+ Err ( e) => {
110
+ let _ = tx. send ( Err ( e. into ( ) ) ) . await ;
111
+ return ;
112
+ }
111
113
Ok ( _) => {
112
114
let len = partial_output. written ( ) . len ( ) ;
113
- //println!("flush(b={b}) with buffer of size {len}");
114
115
let _ = partial_output. into_inner ( ) ;
115
116
buf. resize ( len, 0 ) ;
116
117
if let Err ( _) = tx. send ( Ok ( buf. freeze ( ) ) ) . await {
@@ -129,10 +130,12 @@ where {
129
130
let mut partial_output = PartialBuffer :: new ( buf) ;
130
131
131
132
match self . finish ( & mut partial_output) {
132
- Err ( e) => panic ! ( "{e:?}" ) ,
133
+ Err ( e) => {
134
+ let _ = tx. send ( Err ( e. into ( ) ) ) . await ;
135
+ return ;
136
+ }
133
137
Ok ( _) => {
134
138
let len = partial_output. written ( ) . len ( ) ;
135
- //println!("finish with buffer of size {}", len);
136
139
137
140
let mut buf = partial_output. into_inner ( ) ;
138
141
buf. resize ( len, 0 ) ;
0 commit comments