From cc34729f45aca5c598f6d167a766e31147c12373 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 27 Jul 2024 12:19:08 +0300 Subject: [PATCH] Ticket #4563: support reget in file move operation. * (file_op_context_new): change default value of file_op_context_t::do_reget. * (overwrite_query_dialog): show the "Reget" button in query dialog for move operation. * (copy_file_file): keep non-default value of file_op_context_t::do_reget that was set before. Signed-off-by: Andrew Borodin --- src/filemanager/file.c | 8 ++++++-- src/filemanager/filegui.c | 2 +- src/filemanager/fileopctx.c | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/filemanager/file.c b/src/filemanager/file.c index 8a572fc43..f7f07960c 100644 --- a/src/filemanager/file.c +++ b/src/filemanager/file.c @@ -2274,8 +2274,12 @@ copy_file_file (file_op_total_context_t *tctx, file_op_context_t *ctx, vfs_path_t *src_vpath = NULL, *dst_vpath = NULL; char *buf = NULL; - /* FIXME: We should not be using global variables! */ - ctx->do_reget = 0; + /* Keep the non-default value applied in chain of calls: + move_file_file() -> file_progress_real_query_replace() + move_file_file() -> copy_file_file() */ + if (ctx->do_reget < 0) + ctx->do_reget = 0; + return_status = FILE_RETRY; dst_vpath = vfs_path_from_str (dst_path); diff --git a/src/filemanager/filegui.c b/src/filemanager/filegui.c index 736af9ae7..08f94d97e 100644 --- a/src/filemanager/filegui.c +++ b/src/filemanager/filegui.c @@ -569,7 +569,7 @@ overwrite_query_dialog (file_op_context_t *ctx, enum OperationMode mode) /* will "Append" and "Reget" buttons be in the dialog? */ do_append = !S_ISDIR (ui->dst_stat->st_mode); - do_reget = do_append && ctx->operation == OP_COPY && ui->dst_stat->st_size != 0 + do_reget = do_append && ui->dst_stat->st_size != 0 && ui->src_stat->st_size > ui->dst_stat->st_size; NEW_LABEL (8, dlg_widgets[8].text); diff --git a/src/filemanager/fileopctx.c b/src/filemanager/fileopctx.c index 62d76ae70..1f32664cd 100644 --- a/src/filemanager/fileopctx.c +++ b/src/filemanager/fileopctx.c @@ -74,7 +74,7 @@ file_op_context_new (FileOperation op) ctx->operation = op; ctx->eta_secs = 0.0; ctx->progress_bytes = 0; - ctx->do_reget = 1; + ctx->do_reget = -1; ctx->stat_func = mc_lstat; ctx->preserve = TRUE; ctx->preserve_uidgid = (geteuid () == 0);