diff options
| -rw-r--r-- | locales/help_docs/en.yml | 3 | ||||
| -rw-r--r-- | locales/help_docs/zh-CN.yml | 2 | ||||
| -rw-r--r-- | scripts/completions/bash/completion_jv.sh | 8 | ||||
| -rw-r--r-- | scripts/completions/powershell/completion_jv.ps1 | 8 | ||||
| -rw-r--r-- | src/bin/jv.rs | 38 |
5 files changed, 46 insertions, 13 deletions
diff --git a/locales/help_docs/en.yml b/locales/help_docs/en.yml index ac8dc8c..f03d5b8 100644 --- a/locales/help_docs/en.yml +++ b/locales/help_docs/en.yml @@ -316,6 +316,7 @@ jv: For moved items: jv sheet align <ITEM> [local/remote] - Align specified moved item jv sheet align moved [local/remote] - Align all moved items + jv sheet align moved break - Break all move items For lost items: jv sheet align <ITEM> <CREATED_ITEM> - Point to created item to confirm move @@ -778,6 +779,8 @@ jv: **Suggestion**: Align [[yellow]]Moved Items[[/]], confirm the move is based on Local or Remote **Example**: Use `jv align moved [local|remote]` to batch align or use `jv align %{example_moved} [local|remote]` to precisely align a move + If this move is not what you expected, + use `jv align %{example_moved} break` to break them **Align to Local**: Online , modify the upstream mapping to the local location **Align to Remote**: Offline, move the local file to the upstream location diff --git a/locales/help_docs/zh-CN.yml b/locales/help_docs/zh-CN.yml index ffa566d..ca1f131 100644 --- a/locales/help_docs/zh-CN.yml +++ b/locales/help_docs/zh-CN.yml @@ -770,6 +770,8 @@ jv: **建议**:对齐 [[yellow]]移动项[[/]],确认移动基于 本地 或 远程 **例如**:使用 `jv align moved [local|remote]` 批量对齐 或使用 `jv align %{example_moved} [local|remote]` 精确对齐移动 + 若该移动并非您期望的, + 使用 `jv align %{example_moved} break` 断开它们 **对齐至本地**:联网,修改上游映射至本地位置 **对齐至远程**:脱机,将本地文件移至上游位置 diff --git a/scripts/completions/bash/completion_jv.sh b/scripts/completions/bash/completion_jv.sh index d6743e7..4023e42 100644 --- a/scripts/completions/bash/completion_jv.sh +++ b/scripts/completions/bash/completion_jv.sh @@ -113,11 +113,11 @@ _jv_completion() { elif [[ "$item" == lost:* ]]; then align_operations="confirm $created_items" elif [[ "$item" == "moved" || "$item" == moved:* ]]; then - align_operations="local remote" + align_operations="local remote break" elif [[ "$item" == "erased" || "$item" == erased:* ]]; then align_operations="confirm" else - align_operations="local remote confirm $created_items" + align_operations="local remote confirm break $created_items" fi COMPREPLY=($(compgen -W "$align_operations" -- "$cur")) @@ -145,11 +145,11 @@ _jv_completion() { elif [[ "$item" == lost:* ]]; then align_operations="confirm $created_items" elif [[ "$item" == "moved" || "$item" == moved:* ]]; then - align_operations="local remote" + align_operations="local remote break" elif [[ "$item" == "erased" || "$item" == erased:* ]]; then align_operations="confirm" else - align_operations="local remote confirm $created_items" + align_operations="local remote confirm break $created_items" fi COMPREPLY=($(compgen -W "$align_operations" -- "$cur")) diff --git a/scripts/completions/powershell/completion_jv.ps1 b/scripts/completions/powershell/completion_jv.ps1 index 5027a35..0c854e3 100644 --- a/scripts/completions/powershell/completion_jv.ps1 +++ b/scripts/completions/powershell/completion_jv.ps1 @@ -102,11 +102,11 @@ Register-ArgumentCompleter -Native -CommandName jv -ScriptBlock { } elseif ($item -like "lost:*") { $alignOperations = @("confirm") + $createdItems } elseif ($item -eq "moved" -or $item -like "moved:*") { - $alignOperations = @("local", "remote") + $alignOperations = @("local", "remote", "break") } elseif ($item -eq "erased" -or $item -like "erased:*") { $alignOperations = @("confirm") } else { - $alignOperations = @("local", "remote", "confirm") + $createdItems + $alignOperations = @("local", "remote", "confirm", "break") + $createdItems } return $alignOperations | Where-Object { $_ -like "$wordToComplete*" } @@ -133,11 +133,11 @@ Register-ArgumentCompleter -Native -CommandName jv -ScriptBlock { } elseif ($item -like "lost:*") { $alignOperations = @("confirm") + $createdItems } elseif ($item -eq "moved" -or $item -like "moved:*") { - $alignOperations = @("local", "remote") + $alignOperations = @("local", "remote", "break") } elseif ($item -eq "erased" -or $item -like "erased:*") { $alignOperations = @("confirm") } else { - $alignOperations = @("local", "remote", "confirm") + $createdItems + $alignOperations = @("local", "remote", "confirm", "break") + $createdItems } return $alignOperations | Where-Object { $_ -like "$wordToComplete*" } 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 |
