use eyre::Result;
use tokio::{fs, io, io::AsyncWriteExt};

pub async fn run() -> Result<()> {
    let mut input = io::stdin();
    let mut out = fs::File::create("/bootstrap.tar.part").await?;

    let n = io::copy(&mut input, &mut out).await?;

    out.flush().await?;
    drop(out);

    eprintln!("copied {n} bytes");

    fs::rename("/bootstrap.tar.part", "/bootstrap.tar").await?;
    eprintln!("/bootstrap.tar ready to use");

    Ok(())
}
