Skip to content

Commit 4aed217

Browse files
committed
fix: avoid async-std panic on drop
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
1 parent 0acd244 commit 4aed217

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

crates/wit-deps/src/lib.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,19 @@ where
269269
let path = path.as_ref();
270270
let mut tar = async_tar::Builder::new(dst);
271271
tar.mode(async_tar::HeaderMode::Deterministic);
272-
for name in read_wits(path).await?.try_collect::<BTreeSet<_>>().await? {
273-
tar.append_path_with_name(path.join(&name), Path::new("wit").join(name))
274-
.await?;
272+
let res = async {
273+
for name in read_wits(path).await?.try_collect::<BTreeSet<_>>().await? {
274+
tar.append_path_with_name(path.join(&name), Path::new("wit").join(name))
275+
.await?;
276+
}
277+
std::io::Result::Ok(())
278+
}
279+
.await;
280+
if res.is_err() {
281+
// Finalize the builder to avoid a panic on drop.
282+
let _ = tar.finish().await;
275283
}
284+
res?;
276285
tar.into_inner().await
277286
}
278287

0 commit comments

Comments
 (0)