From 7d73ce1cbe5e009018df6ec6776de258f71673b1 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 7 Apr 2018 13:13:53 +0300 Subject: [PATCH] Ticket: 3908: quiet single file overwrite. If target file exists, MC overwrites that file without confirmation. The bug was introduced in #3149. How to reproduce: 1. Create two files: `touch a aa`. 2. Stay on "aa". 3. Make sure that Options/Confirmation.../Overwrite option is checked on. 4. Press Shift-F6 5. Edit the "to:" value to "a" ("a" file exists) and press Enter. Actual result: The "a" file is overwritten w/o confirmation. Expected result: Since the "a" file exists the confirmation dialog must be shown. The problem is: confirmation dialog requires context UI which was not created in case of single file rename operation. Signed-off-by: Andrew Borodin --- src/filemanager/file.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/filemanager/file.c b/src/filemanager/file.c index 09530c76b..179d8c895 100644 --- a/src/filemanager/file.c +++ b/src/filemanager/file.c @@ -716,6 +716,9 @@ panel_operate_init_totals (const WPanel * panel, const vfs_path_t * source, ctx->progress_totals_computed = FALSE; } + /* destroy already created UI for single file rename operation */ + file_op_context_destroy_ui (ctx); + file_op_context_create_ui (ctx, TRUE, dialog_type); return status; @@ -1948,7 +1951,14 @@ operate_single_file (const WPanel * panel, FileOperation operation, file_op_tota case OP_MOVE: if (is_file) + { +#ifdef ENABLE_BACKGROUND + /* create UI to show confirmation dialog */ + if (!mc_global.we_are_background) + file_op_context_create_ui (ctx, TRUE, FILEGUI_DIALOG_ONE_ITEM); +#endif value = move_file_file (panel, tctx, ctx, src, dest); + } else value = do_move_dir_dir (panel, tctx, ctx, src, dest); break;