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.
This commit is contained in:
ForgQi committed 2025-10-01 01:52:04 +08:00
1 parent af82185618
commit 2fcdb0fe7b
3 files changed
+19 -3

No files matched your search

Generated
+2 -2
View File
@@ -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",
+1 -1
View File
@@ -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"] }
@@ -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(())
}