From 2fcdb0fe7b9a75a66b4b0be760f0802550181a89 Mon Sep 17 00:00:00 2001 From: ForgQi <34411314+ForgQi@users.noreply.github.com> Date: Wed, 1 Oct 2025 01:52:04 +0800 Subject: [PATCH] Move associated XML file with video in HookStep When moving a video file, also check for an associated XML file (e.g., subtitles or metadata) and move it to the target directory if it exists. This ensures related files are kept together during the move operation. --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- .../server/infrastructure/models/hook_step.rs | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9219c4a..7e62547 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -395,7 +395,7 @@ dependencies = [ [[package]] name = "biliup-cli" -version = "1.1.15" +version = "1.1.16" dependencies = [ "async-channel", "async-trait", @@ -3641,7 +3641,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "stream-gears" -version = "1.1.15" +version = "1.1.16" dependencies = [ "async-channel", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 8caf952..9621f53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ members = [ resolver = "3" [workspace.package] -version = "1.1.15" +version = "1.1.16" [workspace.dependencies] serde = { version = "1.0", features = ["derive"] } diff --git a/crates/biliup-cli/src/server/infrastructure/models/hook_step.rs b/crates/biliup-cli/src/server/infrastructure/models/hook_step.rs index 4be3eac..81e1139 100644 --- a/crates/biliup-cli/src/server/infrastructure/models/hook_step.rs +++ b/crates/biliup-cli/src/server/infrastructure/models/hook_step.rs @@ -126,6 +126,22 @@ impl HookStep { fs::rename(video_path, destination) .await .change_context(AppError::Unknown)?; + + let buf = video_path.with_extension("xml"); + if buf.exists() { + let file_name = buf + .file_name() + .ok_or(AppError::Custom("Invalid file name".to_string()))?; + let destination = target_path.join(file_name); + fs::rename(&buf, &destination) + .await + .change_context(AppError::Unknown)?; + info!( + "移动弹幕文件: Moving {} to {}", + buf.display(), + destination.display() + ); + } } Ok(()) }