Skip to content

Commit

Permalink
Aliyun PDS doesn't support trash file
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Oct 27, 2021
1 parent 2099958 commit a4cc552
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct Opt {
#[structopt(short = "w", long)]
workdir: Option<PathBuf>,
/// Delete file permanently instead of trashing it
#[structopt(long)]
#[structopt(long, conflicts_with = "domain-id")]
no_trash: bool,
/// Aliyun PDS domain id
#[structopt(long)]
Expand All @@ -75,28 +75,37 @@ async fn main() -> anyhow::Result<()> {
anyhow::bail!("auth-user and auth-password should be specified together.");
}

let drive_config = if let Some(domain_id) = opt.domain_id {
DriveConfig {
api_base_url: format!("https://{}.api.aliyunpds.com", domain_id),
refresh_token_url: format!("https://{}.auth.aliyunpds.com/v2/account/token", domain_id),
workdir: opt.workdir,
app_id: Some("BasicUI".to_string()),
}
let (drive_config, no_trash) = if let Some(domain_id) = opt.domain_id {
(
DriveConfig {
api_base_url: format!("https://{}.api.aliyunpds.com", domain_id),
refresh_token_url: format!(
"https://{}.auth.aliyunpds.com/v2/account/token",
domain_id
),
workdir: opt.workdir,
app_id: Some("BasicUI".to_string()),
},
true, // PDS doesn't have trash support
)
} else {
DriveConfig {
api_base_url: "https://api.aliyundrive.com".to_string(),
refresh_token_url: "https://websv.aliyundrive.com/token/refresh".to_string(),
workdir: opt.workdir,
app_id: None,
}
(
DriveConfig {
api_base_url: "https://api.aliyundrive.com".to_string(),
refresh_token_url: "https://websv.aliyundrive.com/token/refresh".to_string(),
workdir: opt.workdir,
app_id: None,
},
opt.no_trash,
)
};
let fs = AliyunDriveFileSystem::new(
drive_config,
opt.refresh_token,
opt.root,
opt.cache_size,
opt.cache_ttl,
opt.no_trash,
no_trash,
)
.await
.map_err(|_| {
Expand Down

0 comments on commit a4cc552

Please sign in to comment.