From 681617cf0278549bd7576113eb41beb2e1a6dd37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=80=E1=B4=8D=E1=B4=9B=E1=B4=8F=E1=B4=80=E1=B4=87?= =?UTF-8?q?=CA=80?= Date: Tue, 24 Feb 2026 23:24:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BC=95=E5=85=A5=20dunce=20=E5=BA=93?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=8C=96=E8=B7=AF=E5=BE=84=EF=BC=8C=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=89=8B=E5=86=99=E7=9A=84=E8=A7=84=E8=8C=83=E5=8C=96?= =?UTF-8?q?=E9=80=BB=E8=BE=91=20(#658)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + crates/bili_sync/Cargo.toml | 1 + crates/bili_sync/src/workflow.rs | 11 +++-------- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fbd55c2..7bf95e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -370,6 +370,7 @@ dependencies = [ "croner", "dashmap", "dirs", + "dunce", "enum_dispatch", "float-ord", "futures", @@ -1087,6 +1088,12 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "either" version = "1.15.0" diff --git a/Cargo.toml b/Cargo.toml index 556fad8..4ff066d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ croner = "3.0.1" dashmap = "6.1.0" derivative = "2.2.0" dirs = "6.0.0" +dunce = "1.0.5" enum_dispatch = "0.3.13" float-ord = "0.3.2" futures = "0.3.31" diff --git a/crates/bili_sync/Cargo.toml b/crates/bili_sync/Cargo.toml index 31482bb..9caa4a6 100644 --- a/crates/bili_sync/Cargo.toml +++ b/crates/bili_sync/Cargo.toml @@ -24,6 +24,7 @@ cookie = { workspace = true } croner = { workspace = true } dashmap = { workspace = true } dirs = { workspace = true } +dunce = { workspace = true } enum_dispatch = { workspace = true } float-ord = { workspace = true } futures = { workspace = true } diff --git a/crates/bili_sync/src/workflow.rs b/crates/bili_sync/src/workflow.rs index 3aa16b2..39fde5e 100644 --- a/crates/bili_sync/src/workflow.rs +++ b/crates/bili_sync/src/workflow.rs @@ -236,14 +236,8 @@ pub async fn download_video_pages( .path_safe_render("video", &video_format_args(&video_model, &cx.config.time_format))?, ) }; - - #[cfg(target_family = "windows")] - // windows 系统不允许文件和文件夹以空格结尾,文件有拓展名不会出错,但文件夹可能以空格结尾,需要处理下 - // 此处如果不做修改,创建文件夹操作可以成功,系统会自动创建一个无结尾空格的版本 - // 但由于该路径还用于后续的路径拼接,如果不处理,其它文件路径拼接时使用的还是带结尾空格的版本 - // 导致拼接完的路径不合法,后续的文件操作失败,提示“系统找不到指定的路径” - let base_path = PathBuf::from(base_path.to_string_lossy().trim_end()); - + fs::create_dir_all(&base_path).await?; + let base_path = dunce::canonicalize(base_path).context("canonicalize video path failed")?; let upper_id = video_model.upper_id.to_string(); let base_upper_path = cx .config @@ -424,6 +418,7 @@ pub async fn download_page( )?, ) }; + let base_path = dunce::canonicalize(base_path).context("canonicalize base path failed")?; let (poster_path, video_path, nfo_path, danmaku_path, fanart_path, subtitle_path) = if is_single_page { ( base_path.join(format!("{}-poster.jpg", &base_name)),