summaryrefslogtreecommitdiff
path: root/src/bin/jv.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-03 15:15:43 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-03 15:15:43 +0800
commit706de616460a8b3698accca679e44a98ab5c00aa (patch)
tree951834c8d12aa71e438bbdf2c479fd6dab41b6f4 /src/bin/jv.rs
parentbaeee2f316c8c9ccab3da15943b478aed99c6cad (diff)
Add break option to align moved command
Diffstat (limited to 'src/bin/jv.rs')
-rw-r--r--src/bin/jv.rs38
1 files changed, 33 insertions, 5 deletions
diff --git a/src/bin/jv.rs b/src/bin/jv.rs
index 55248ab..341d40b 100644
--- a/src/bin/jv.rs
+++ b/src/bin/jv.rs
@@ -2575,9 +2575,10 @@ async fn jv_sheet_align(args: SheetAlignArgs) {
// Move: alignment mode
if task.starts_with("moved") {
- let align_to_remote = match to.trim().to_lowercase().as_str() {
- "remote" => true,
- "local" => false,
+ let align_to = match to.trim().to_lowercase().as_str() {
+ "remote" => "remote",
+ "local" => "local",
+ "break" => "break",
_ => {
eprintln!("{}", md(t!("jv.fail.sheet.align.unknown_moved_direction")));
return;
@@ -2612,7 +2613,7 @@ async fn jv_sheet_align(args: SheetAlignArgs) {
.collect()
};
- if !align_to_remote {
+ if align_to == "local" {
// Align to local
// Network move mapping
let (pool, ctx, _output) = match build_pool_and_ctx(&local_cfg).await {
@@ -2622,7 +2623,7 @@ async fn jv_sheet_align(args: SheetAlignArgs) {
// Process mapping edit, errors are handled internally
let _ = proc_mapping_edit(&pool, ctx, EditMappingActionArguments { operations }).await;
- } else {
+ } else if align_to == "remote" {
// Align to remote
// Offline move files
for (remote_path, (_, local_path)) in operations {
@@ -2661,6 +2662,33 @@ async fn jv_sheet_align(args: SheetAlignArgs) {
eprintln!("{}", md(t!("jv.fail.sheet.align.move_failed", err = err)));
}
}
+ } else if align_to == "break" {
+ for (remote_path, (_, _)) in operations {
+ let Ok(mapping) = local_sheet.mapping_data_mut(&remote_path) else {
+ eprintln!(
+ "{}",
+ md(t!(
+ "jv.fail.sheet.align.mapping_not_found",
+ mapping = remote_path.display()
+ ))
+ );
+ return;
+ };
+
+ // Restore the latest detected hash to the original hash,
+ // making the analyzer unable to correctly match
+ //
+ // That is to say,
+ // if the file's hash has remained completely unchanged from the beginning to the end,
+ // then break is also ineffective.
+ mapping.set_last_modifiy_check_hash(Some(mapping.hash_when_updated().clone()));
+ }
+
+ // Save sheet
+ let Ok(_) = local_sheet.write().await else {
+ eprintln!("{}", t!("jv.fail.write_cfg").trim());
+ return;
+ };
}
}
// Lost: match or confirm mode