49 lines
1.1 KiB
Rust
49 lines
1.1 KiB
Rust
mod appstate;
|
|
mod cli;
|
|
mod sharry;
|
|
|
|
use clap::Parser;
|
|
use log::{error, info};
|
|
use ureq::Agent;
|
|
|
|
use appstate::AppState;
|
|
use cli::Cli;
|
|
use sharry::Share;
|
|
|
|
fn main() {
|
|
env_logger::init();
|
|
|
|
let args = Cli::parse();
|
|
info!("args: {args:?}");
|
|
info!("timeout: {:?}", args.get_timeout());
|
|
|
|
let agent: Agent = Agent::config_builder()
|
|
.timeout_global(args.get_timeout())
|
|
.build()
|
|
.into();
|
|
|
|
if let Some(state) = AppState::try_resume(&args) {
|
|
info!("state: {state:?}");
|
|
}
|
|
|
|
let alias = args.get_alias();
|
|
let share = Share::create(&agent, &alias, args.get_share_request()).unwrap();
|
|
info!("share: {share:?}");
|
|
|
|
for file in args.files {
|
|
let file = file.create(&agent, &alias, &share).unwrap();
|
|
info!("file: {file:?}");
|
|
|
|
for chunk in file.chunked(args.chunk_size * 1024 * 1024).seek(0) {
|
|
info!("chunk: {chunk:?}");
|
|
|
|
file.upload_chunk(&agent, &alias, &chunk)
|
|
.unwrap_or_else(|e| {
|
|
error!("error: {e}");
|
|
panic!("{e}");
|
|
});
|
|
}
|
|
}
|
|
|
|
share.notify(&agent, &alias).unwrap();
|
|
}
|