(file_error): allow show query dialog w/o Rerty action.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2018-10-11 13:17:51 +03:00
parent 022f15d9f0
commit 0f0dbc2b2e
3 changed files with 62 additions and 45 deletions

View File

@ -427,7 +427,7 @@ make_symlink (file_op_context_t * ctx, const char *src_path, const char *dst_pat
return_status = FILE_SKIPALL;
else
{
return_status = file_error (_("Cannot read source link \"%s\"\n%s"), src_path);
return_status = file_error (TRUE, _("Cannot read source link \"%s\"\n%s"), src_path);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
if (return_status == FILE_RETRY)
@ -510,7 +510,7 @@ make_symlink (file_op_context_t * ctx, const char *src_path, const char *dst_pat
return_status = FILE_SKIPALL;
else
{
return_status = file_error (_("Cannot create target symlink \"%s\"\n%s"), dst_path);
return_status = file_error (TRUE, _("Cannot create target symlink \"%s\"\n%s"), dst_path);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
if (return_status == FILE_RETRY)
@ -828,14 +828,19 @@ get_times (const struct stat *sb, mc_timesbuf_t * times)
/* {{{ Query/status report routines */
static FileProgressStatus
real_do_file_error (enum OperationMode mode, const char *error)
real_do_file_error (enum OperationMode mode, gboolean allow_retry, const char *error)
{
int result;
const char *msg;
msg = mode == Foreground ? MSG_ERROR : _("Background process error");
result =
query_dialog (msg, error, D_ERROR, 4, _("&Skip"), _("Ski&p all"), _("&Retry"), _("&Abort"));
if (allow_retry)
result =
query_dialog (msg, error, D_ERROR, 4, _("&Skip"), _("Ski&p all"), _("&Retry"),
_("&Abort"));
else
result = query_dialog (msg, error, D_ERROR, 4, _("&Skip"), _("Ski&p all"), _("&Abort"));
switch (result)
{
@ -848,8 +853,12 @@ real_do_file_error (enum OperationMode mode, const char *error)
return FILE_SKIPALL;
case 2:
do_refresh ();
return FILE_RETRY;
if (allow_retry)
{
do_refresh ();
return FILE_RETRY;
}
MC_FALLTHROUGH;
case 3:
default:
@ -904,22 +913,22 @@ real_query_recursive (file_op_context_t * ctx, enum OperationMode mode, const ch
#ifdef ENABLE_BACKGROUND
static FileProgressStatus
do_file_error (const char *str)
do_file_error (gboolean allow_retry, const char *str)
{
/* *INDENT-OFF* */
union
{
void *p;
FileProgressStatus (*f) (enum OperationMode, const char *);
FileProgressStatus (*f) (enum OperationMode, gboolean, const char *);
} pntr;
/* *INDENT-ON* */
pntr.f = real_do_file_error;
if (mc_global.we_are_background)
return parent_call (pntr.p, NULL, 1, strlen (str), str);
return parent_call (pntr.p, NULL, 2, sizeof (allow_retry), allow_retry, strlen (str), str);
else
return real_do_file_error (Foreground, str);
return real_do_file_error (Foreground, allow_retry, str);
}
/* --------------------------------------------------------------------------------------------- */
@ -971,9 +980,9 @@ query_replace (file_op_context_t * ctx, const char *destname, struct stat *_s_st
/* --------------------------------------------------------------------------------------------- */
static FileProgressStatus
do_file_error (const char *str)
do_file_error (gboolean allow_retry, const char *str)
{
return real_do_file_error (Foreground, str);
return real_do_file_error (Foreground, allow_retry, str);
}
/* --------------------------------------------------------------------------------------------- */
@ -1010,7 +1019,7 @@ files_error (const char *format, const char *file1, const char *file2)
g_free (nfile1);
g_free (nfile2);
return do_file_error (buf);
return do_file_error (TRUE, buf);
}
/* }}} */
@ -1076,7 +1085,7 @@ try_remove_file (file_op_context_t * ctx, const vfs_path_t * vpath, FileProgress
{
while (mc_unlink (vpath) != 0 && !ctx->skip_all)
{
*status = file_error (_("Cannot remove file \"%s\"\n%s"), vfs_path_as_str (vpath));
*status = file_error (TRUE, _("Cannot remove file \"%s\"\n%s"), vfs_path_as_str (vpath));
if (*status == FILE_RETRY)
continue;
if (*status == FILE_SKIPALL)
@ -1134,7 +1143,7 @@ move_file_file (const WPanel * panel, file_op_total_context_t * tctx, file_op_co
return_status = FILE_SKIPALL;
else
{
return_status = file_error (_("Cannot stat file \"%s\"\n%s"), s);
return_status = file_error (TRUE, _("Cannot stat file \"%s\"\n%s"), s);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
}
@ -1299,7 +1308,7 @@ try_erase_dir (file_op_context_t * ctx, const char *dir)
while (my_rmdir (dir) != 0 && !ctx->skip_all)
{
return_status = file_error (_("Cannot remove directory \"%s\"\n%s"), dir);
return_status = file_error (TRUE, _("Cannot remove directory \"%s\"\n%s"), dir);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
if (return_status != FILE_RETRY)
@ -1527,9 +1536,9 @@ do_move_dir_dir (const WPanel * panel, file_op_total_context_t * tctx, file_op_c
else
{
if (S_ISDIR (dbuf.st_mode))
return_status = file_error (_("Cannot overwrite directory \"%s\"\n%s"), d);
return_status = file_error (TRUE, _("Cannot overwrite directory \"%s\"\n%s"), d);
else
return_status = file_error (_("Cannot overwrite file \"%s\"\n%s"), d);
return_status = file_error (TRUE, _("Cannot overwrite file \"%s\"\n%s"), d);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
if (return_status == FILE_RETRY)
@ -2144,7 +2153,8 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
return_status = FILE_SKIPALL;
else
{
return_status = file_error (_("Cannot overwrite directory \"%s\"\n%s"), dst_path);
return_status =
file_error (TRUE, _("Cannot overwrite directory \"%s\"\n%s"), dst_path);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
if (return_status == FILE_RETRY)
@ -2163,7 +2173,7 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
return_status = FILE_SKIPALL;
else
{
return_status = file_error (_("Cannot stat source file \"%s\"\n%s"), src_path);
return_status = file_error (TRUE, _("Cannot stat source file \"%s\"\n%s"), src_path);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
}
@ -2216,7 +2226,8 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
while (mc_mknod (dst_vpath, src_stat.st_mode & ctx->umask_kill, rdev) < 0
&& !ctx->skip_all)
{
return_status = file_error (_("Cannot create special file \"%s\"\n%s"), dst_path);
return_status =
file_error (TRUE, _("Cannot create special file \"%s\"\n%s"), dst_path);
if (return_status == FILE_RETRY)
continue;
if (return_status == FILE_SKIPALL)
@ -2228,7 +2239,7 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
while (ctx->preserve_uidgid
&& mc_chown (dst_vpath, src_stat.st_uid, src_stat.st_gid) != 0 && !ctx->skip_all)
{
temp_status = file_error (_("Cannot chown target file \"%s\"\n%s"), dst_path);
temp_status = file_error (TRUE, _("Cannot chown target file \"%s\"\n%s"), dst_path);
if (temp_status == FILE_SKIP)
break;
if (temp_status == FILE_SKIPALL)
@ -2243,7 +2254,7 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
while (ctx->preserve && mc_chmod (dst_vpath, src_stat.st_mode & ctx->umask_kill) != 0
&& !ctx->skip_all)
{
temp_status = file_error (_("Cannot chmod target file \"%s\"\n%s"), dst_path);
temp_status = file_error (TRUE, _("Cannot chmod target file \"%s\"\n%s"), dst_path);
if (temp_status == FILE_SKIP)
break;
if (temp_status == FILE_SKIPALL)
@ -2264,7 +2275,7 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
while ((src_desc = mc_open (src_vpath, O_RDONLY | O_LINEAR)) < 0 && !ctx->skip_all)
{
return_status = file_error (_("Cannot open source file \"%s\"\n%s"), src_path);
return_status = file_error (TRUE, _("Cannot open source file \"%s\"\n%s"), src_path);
if (return_status == FILE_RETRY)
continue;
if (return_status == FILE_SKIPALL)
@ -2291,7 +2302,7 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
return_status = FILE_SKIPALL;
else
{
return_status = file_error (_("Cannot fstat source file \"%s\"\n%s"), src_path);
return_status = file_error (TRUE, _("Cannot fstat source file \"%s\"\n%s"), src_path);
if (return_status == FILE_RETRY)
continue;
if (return_status == FILE_SKIPALL)
@ -2328,7 +2339,8 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
return_status = FILE_SKIPALL;
else
{
return_status = file_error (_("Cannot create target file \"%s\"\n%s"), dst_path);
return_status =
file_error (TRUE, _("Cannot create target file \"%s\"\n%s"), dst_path);
if (return_status == FILE_RETRY)
continue;
if (return_status == FILE_SKIPALL)
@ -2358,7 +2370,7 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
return_status = FILE_SKIPALL;
else
{
return_status = file_error (_("Cannot fstat target file \"%s\"\n%s"), dst_path);
return_status = file_error (TRUE, _("Cannot fstat target file \"%s\"\n%s"), dst_path);
if (return_status == FILE_RETRY)
continue;
if (return_status == FILE_SKIPALL)
@ -2379,7 +2391,7 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
}
return_status =
file_error (_("Cannot preallocate space for target file \"%s\"\n%s"), dst_path);
file_error (TRUE, _("Cannot preallocate space for target file \"%s\"\n%s"), dst_path);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
@ -2435,7 +2447,8 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
if (mc_ctl (src_desc, VFS_CTL_IS_NOTREADY, 0) == 0)
while ((n_read = mc_read (src_desc, buf, bufsize)) < 0 && !ctx->skip_all)
{
return_status = file_error (_("Cannot read source file \"%s\"\n%s"), src_path);
return_status =
file_error (TRUE, _("Cannot read source file \"%s\"\n%s"), src_path);
if (return_status == FILE_RETRY)
continue;
if (return_status == FILE_SKIPALL)
@ -2480,7 +2493,7 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
return_status = FILE_SKIPALL;
else
return_status =
file_error (_("Cannot write target file \"%s\"\n%s"), dst_path);
file_error (TRUE, _("Cannot write target file \"%s\"\n%s"), dst_path);
if (return_status == FILE_SKIP)
{
@ -2553,7 +2566,7 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
rotate_dash (FALSE);
while (src_desc != -1 && mc_close (src_desc) < 0 && !ctx->skip_all)
{
temp_status = file_error (_("Cannot close source file \"%s\"\n%s"), src_path);
temp_status = file_error (TRUE, _("Cannot close source file \"%s\"\n%s"), src_path);
if (temp_status == FILE_RETRY)
continue;
if (temp_status == FILE_ABORT)
@ -2565,7 +2578,7 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
while (dest_desc != -1 && mc_close (dest_desc) < 0 && !ctx->skip_all)
{
temp_status = file_error (_("Cannot close target file \"%s\"\n%s"), dst_path);
temp_status = file_error (TRUE, _("Cannot close target file \"%s\"\n%s"), dst_path);
if (temp_status == FILE_RETRY)
continue;
if (temp_status == FILE_SKIPALL)
@ -2588,7 +2601,7 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
{
while (mc_chown (dst_vpath, src_uid, src_gid) != 0 && !ctx->skip_all)
{
temp_status = file_error (_("Cannot chown target file \"%s\"\n%s"), dst_path);
temp_status = file_error (TRUE, _("Cannot chown target file \"%s\"\n%s"), dst_path);
if (temp_status == FILE_RETRY)
continue;
if (temp_status == FILE_SKIPALL)
@ -2608,7 +2621,8 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
{
while (mc_chmod (dst_vpath, (src_mode & ctx->umask_kill)) != 0 && !ctx->skip_all)
{
temp_status = file_error (_("Cannot chmod target file \"%s\"\n%s"), dst_path);
temp_status =
file_error (TRUE, _("Cannot chmod target file \"%s\"\n%s"), dst_path);
if (temp_status == FILE_RETRY)
continue;
if (temp_status == FILE_SKIPALL)
@ -2673,7 +2687,7 @@ copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha
return_status = FILE_SKIPALL;
else
{
return_status = file_error (_("Cannot stat source directory \"%s\"\n%s"), s);
return_status = file_error (TRUE, _("Cannot stat source directory \"%s\"\n%s"), s);
if (return_status == FILE_RETRY)
goto retry_src_stat;
if (return_status == FILE_SKIPALL)
@ -2706,7 +2720,7 @@ copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha
return_status = FILE_SKIPALL;
else
{
return_status = file_error (_("Source \"%s\" is not a directory\n%s"), s);
return_status = file_error (TRUE, _("Source \"%s\" is not a directory\n%s"), s);
if (return_status == FILE_RETRY)
goto retry_src_stat;
if (return_status == FILE_SKIPALL)
@ -2756,7 +2770,8 @@ copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha
return_status = FILE_SKIPALL;
else
{
return_status = file_error (_("Destination \"%s\" must be a directory\n%s"), d);
return_status =
file_error (TRUE, _("Destination \"%s\" must be a directory\n%s"), d);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
if (return_status == FILE_RETRY)
@ -2788,7 +2803,8 @@ copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha
return_status = FILE_SKIPALL;
else
{
return_status = file_error (_("Cannot create target directory \"%s\"\n%s"), d);
return_status =
file_error (TRUE, _("Cannot create target directory \"%s\"\n%s"), d);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
}
@ -2812,7 +2828,7 @@ copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha
return_status = FILE_SKIPALL;
else
{
return_status = file_error (_("Cannot chown target directory \"%s\"\n%s"), d);
return_status = file_error (TRUE, _("Cannot chown target directory \"%s\"\n%s"), d);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
}
@ -3239,7 +3255,8 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
break;
if (ctx->skip_all
|| file_error (_("Destination \"%s\" must be a directory\n%s"), dest) != FILE_RETRY)
|| file_error (TRUE, _("Destination \"%s\" must be a directory\n%s"),
dest) != FILE_RETRY)
goto clean_up;
}
@ -3339,13 +3356,13 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
/* {{{ Query/status report routines */
/** Report error with one file */
FileProgressStatus
file_error (const char *format, const char *file)
file_error (gboolean allow_retry, const char *format, const char *file)
{
char buf[BUF_MEDIUM];
g_snprintf (buf, sizeof (buf), format, path_trunc (file, 30), unix_error_string (errno));
return do_file_error (buf);
return do_file_error (allow_retry, buf);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -57,7 +57,7 @@ gboolean panel_operate (void *source_panel, FileOperation op, gboolean force_sin
/* Error reporting routines */
/* Report error with one file */
FileProgressStatus file_error (const char *format, const char *file);
FileProgressStatus file_error (gboolean allow_retry, const char *format, const char *file);
/* return value is FILE_CONT or FILE_ABORT */
FileProgressStatus compute_dir_size (const vfs_path_t * dirname_vpath, dirsize_status_msg_t * sm,

View File

@ -770,7 +770,7 @@ tree_move (WTree * tree, const char *default_dest)
if (!S_ISDIR (buf.st_mode))
{
file_error (_("Destination \"%s\" must be a directory\n%s"), dest);
file_error (TRUE, _("Destination \"%s\" must be a directory\n%s"), dest);
goto ret;
}