Skip to content

Commit 20d0ef8

Browse files
Return Err from ZstdEncoder rather than sending it on the result channel
If anything goes wrong at any point, short circuting and stopping the thread would be the better option Signed-off-by: Pragyan Poudyal <[email protected]>
1 parent e00f422 commit 20d0ef8

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/zstd_encoder.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ pub(crate) enum WriterMode {
4141

4242
pub(crate) struct MultipleZstdWriters {
4343
writers: Vec<ZstdWriter>,
44-
final_result_sender: ResultChannelSender,
4544
}
4645

4746
impl MultipleZstdWriters {
@@ -52,8 +51,6 @@ impl MultipleZstdWriters {
5251
final_result_sender: ResultChannelSender,
5352
) -> Self {
5453
Self {
55-
final_result_sender: final_result_sender.clone(),
56-
5754
writers: sha256
5855
.iter()
5956
.map(|sha| {
@@ -104,10 +101,9 @@ impl MultipleZstdWriters {
104101
}
105102
}
106103

107-
Err(e) => self
108-
.final_result_sender
109-
.send(Err(e))
110-
.context("Failed to send result on channel")?,
104+
Err(e) => {
105+
return Err(e);
106+
}
111107
}
112108

113109
if finished_writers == total_writers {

0 commit comments

Comments
 (0)