mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-08-28 03:28:05 +08:00
fix: 引入 dunce 库规范化路径,移除手写的规范化逻辑 (#658)
This commit is contained in:
Generated
+7
@@ -370,6 +370,7 @@ dependencies = [
|
|||||||
"croner",
|
"croner",
|
||||||
"dashmap",
|
"dashmap",
|
||||||
"dirs",
|
"dirs",
|
||||||
|
"dunce",
|
||||||
"enum_dispatch",
|
"enum_dispatch",
|
||||||
"float-ord",
|
"float-ord",
|
||||||
"futures",
|
"futures",
|
||||||
@@ -1087,6 +1088,12 @@ version = "0.15.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dunce"
|
||||||
|
version = "1.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.15.0"
|
version = "1.15.0"
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ croner = "3.0.1"
|
|||||||
dashmap = "6.1.0"
|
dashmap = "6.1.0"
|
||||||
derivative = "2.2.0"
|
derivative = "2.2.0"
|
||||||
dirs = "6.0.0"
|
dirs = "6.0.0"
|
||||||
|
dunce = "1.0.5"
|
||||||
enum_dispatch = "0.3.13"
|
enum_dispatch = "0.3.13"
|
||||||
float-ord = "0.3.2"
|
float-ord = "0.3.2"
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ cookie = { workspace = true }
|
|||||||
croner = { workspace = true }
|
croner = { workspace = true }
|
||||||
dashmap = { workspace = true }
|
dashmap = { workspace = true }
|
||||||
dirs = { workspace = true }
|
dirs = { workspace = true }
|
||||||
|
dunce = { workspace = true }
|
||||||
enum_dispatch = { workspace = true }
|
enum_dispatch = { workspace = true }
|
||||||
float-ord = { workspace = true }
|
float-ord = { workspace = true }
|
||||||
futures = { workspace = true }
|
futures = { workspace = true }
|
||||||
|
|||||||
@@ -236,14 +236,8 @@ pub async fn download_video_pages(
|
|||||||
.path_safe_render("video", &video_format_args(&video_model, &cx.config.time_format))?,
|
.path_safe_render("video", &video_format_args(&video_model, &cx.config.time_format))?,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
fs::create_dir_all(&base_path).await?;
|
||||||
#[cfg(target_family = "windows")]
|
let base_path = dunce::canonicalize(base_path).context("canonicalize video path failed")?;
|
||||||
// windows 系统不允许文件和文件夹以空格结尾,文件有拓展名不会出错,但文件夹可能以空格结尾,需要处理下
|
|
||||||
// 此处如果不做修改,创建文件夹操作可以成功,系统会自动创建一个无结尾空格的版本
|
|
||||||
// 但由于该路径还用于后续的路径拼接,如果不处理,其它文件路径拼接时使用的还是带结尾空格的版本
|
|
||||||
// 导致拼接完的路径不合法,后续的文件操作失败,提示“系统找不到指定的路径”
|
|
||||||
let base_path = PathBuf::from(base_path.to_string_lossy().trim_end());
|
|
||||||
|
|
||||||
let upper_id = video_model.upper_id.to_string();
|
let upper_id = video_model.upper_id.to_string();
|
||||||
let base_upper_path = cx
|
let base_upper_path = cx
|
||||||
.config
|
.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 {
|
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)),
|
base_path.join(format!("{}-poster.jpg", &base_name)),
|
||||||
|
|||||||
Reference in New Issue
Block a user