pub mod wizard;
mod worker;
use std::path::PathBuf;
use crate::core::job::Job;
pub(crate) use worker::{RcloneCopyPlan, RcloneCopySummary, RcloneDeletePlan, RcloneDeleteSummary};
pub(crate) struct RcloneCopyJob {
pub source: String,
pub destination: String,
pub log_path: PathBuf,
pub transfers: usize,
pub checkers: usize,
pub tpslimit: Option<usize>,
}
impl Job for RcloneCopyJob {
type Plan = RcloneCopyPlan;
type Summary = RcloneCopySummary;
async fn gather(&self) -> Result<RcloneCopyPlan, String> {
Ok(RcloneCopyPlan {
source: self.source.clone(),
destination: self.destination.clone(),
log_path: self.log_path.clone(),
transfers: self.transfers,
checkers: self.checkers,
tpslimit: self.tpslimit,
})
}
async fn run(
self,
plan: RcloneCopyPlan,
_concurrency: usize,
_upload_concurrency: usize,
) -> Result<RcloneCopySummary, String> {
worker::run_copy_job(
&plan.source,
&plan.destination,
&plan.log_path,
plan.transfers,
plan.checkers,
plan.tpslimit,
)
.await
}
}
pub(crate) struct RcloneDeleteJob {
pub source: String,
pub log_path: PathBuf,
pub checkers: usize,
}
impl Job for RcloneDeleteJob {
type Plan = RcloneDeletePlan;
type Summary = RcloneDeleteSummary;
async fn gather(&self) -> Result<RcloneDeletePlan, String> {
Ok(RcloneDeletePlan {
source: self.source.clone(),
log_path: self.log_path.clone(),
checkers: self.checkers,
})
}
async fn run(
self,
plan: RcloneDeletePlan,
_concurrency: usize,
_upload_concurrency: usize,
) -> Result<RcloneDeleteSummary, String> {
worker::run_delete_job(&plan.source, &plan.log_path, plan.checkers).await
}
}