fix: Speedtest not registering number of bytes read
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{
|
||||
cli::UploadInfo,
|
||||
commands::{connect::config::Config, upload::{chunk_reader::ChunkReader, uploadable::OperatorBuilder}},
|
||||
commands::{
|
||||
connect::config::Config,
|
||||
upload::{chunk_reader::ChunkReader, uploadable::OperatorBuilder},
|
||||
},
|
||||
manifest::generate_manifest,
|
||||
};
|
||||
use futures::AsyncWriteExt;
|
||||
use log::info;
|
||||
use tokio_util::compat::FuturesAsyncWriteCompatExt;
|
||||
|
||||
@@ -13,20 +17,25 @@ pub async fn upload(info: &UploadInfo, config: Config) -> anyhow::Result<()> {
|
||||
let path = &info.path;
|
||||
let version_id = &info.version_id;
|
||||
|
||||
let manifest = generate_manifest(&Path::new(path)).await?;
|
||||
let manifest = generate_manifest(Path::new(path)).await?;
|
||||
let operator = match info.upload_style {
|
||||
crate::cli::UploadStyle::S3 => config
|
||||
.get_active_s3()
|
||||
.ok_or(anyhow::Error::msg("Could not get active S3 value"))?.build()?,
|
||||
.get_active_s3()
|
||||
.ok_or(anyhow::Error::msg("Could not get active S3 value"))?
|
||||
.build()?,
|
||||
};
|
||||
info!("Uploading chunks");
|
||||
for (id, data) in &manifest.chunks {
|
||||
info!("Uploading chunk id {id}");
|
||||
let mut reader = ChunkReader::new(&path, data);
|
||||
let mut writer = operator.writer(&format!("{game_id}/{version_id}/{id}")).await?.into_futures_async_write().compat_write();
|
||||
tokio::io::copy(&mut reader, &mut writer);
|
||||
let mut reader = ChunkReader::new(path, data);
|
||||
let mut writer = operator
|
||||
.writer(&format!("{game_id}/{version_id}/{id}"))
|
||||
.await?
|
||||
.into_futures_async_write()
|
||||
.compat_write();
|
||||
tokio::io::copy(&mut reader, &mut writer).await?;
|
||||
writer.into_inner().close().await?;
|
||||
}
|
||||
info!("Finished uploading chunks");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user