-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Labels
help wantedExtra attention is neededExtra attention is needed
Description
Builder::finish() doesn't seem to flush the state of the inner writer. this means the following snippet doesn't work-
use async_compression::futures::write::GzipEncoder;
use async_std::{fs::File, path::Path};
use async_tar::Builder;
use futures::io::AsyncWrite;
async fn write_archive<W>(writer: W, src_directory: impl AsRef<Path>) -> std::io::Result<()>
where
W: AsyncWrite + Unpin + Send + Sync,
{
let mut archive_builder = Builder::new(writer);
archive_builder.append_dir_all("", src_directory).await?;
archive_builder.finish().await
}
#[async_std::main]
async fn main() {
let file = File::create("foo.tar.gz").await.unwrap();
let encoder = GzipEncoder::new(file);
write_archive(encoder, "sample-directory").await.unwrap();
}but this snippet does work
use async_compression::futures::write::GzipEncoder;
use async_std::{fs::File, path::Path};
use async_tar::Builder;
use futures::io::{AsyncWrite, AsyncWriteExt};
async fn write_archive<W>(writer: W, src_directory: impl AsRef<Path>) -> std::io::Result<()>
where
W: AsyncWrite + Unpin + Send + Sync,
{
let mut archive_builder = Builder::new(writer);
archive_builder.append_dir_all("", src_directory).await?;
archive_builder.finish().await?;
archive_builder.into_inner().await?.close().await
}
#[async_std::main]
async fn main() {
let file = File::create("foo.tar.gz").await.unwrap();
let encoder = GzipEncoder::new(file);
write_archive(encoder, "docker-context").await.unwrap();
}that's more than a little surprising.
Builder::finish() should flush the inner writer, or at the very least, this behaviour should be clearly documented
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed