(operate_single_file): don't calculate directory size before rename or move...

...of single directory within same file system.

First try rename the single file/dir. If case of unsuccess, use
copy+delete with directory size calclulation.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2017-04-09 11:00:41 +03:00
parent ef5d346dd9
commit 7dac8f7bd6

View File

@ -1695,19 +1695,19 @@ operate_single_file (const WPanel * panel, FileOperation operation, file_op_tota
else
src_vpath = vfs_path_append_new (panel->cwd_vpath, src, (char *) NULL);
value = panel_operate_init_totals (panel, src_vpath, src_stat, ctx, dialog_type);
if (value != FILE_CONT)
goto ret;
is_file = !S_ISDIR (src_stat->st_mode);
if (operation == OP_DELETE)
{
value = panel_operate_init_totals (panel, src_vpath, src_stat, ctx, dialog_type);
if (value == FILE_CONT)
{
if (is_file)
value = erase_file (tctx, ctx, src_vpath);
else
value = erase_dir (tctx, ctx, src_vpath);
}
}
else
{
char *temp;
@ -1731,20 +1731,45 @@ operate_single_file (const WPanel * panel, FileOperation operation, file_op_tota
vfs_path_free (src_vpath);
src_vpath = vfs_path_from_str (src);
ctx->stat_func (src_vpath, src_stat);
value = panel_operate_init_totals (panel, src_vpath, src_stat, ctx, dialog_type);
if (value == FILE_CONT)
{
is_file = !S_ISDIR (src_stat->st_mode);
if (is_file)
value = copy_file_file (tctx, ctx, src, dest);
else
value = copy_dir_dir (tctx, ctx, src, dest, TRUE, FALSE, FALSE, NULL);
}
break;
case OP_MOVE:
{
vfs_path_t *dest_vpath;
dest_vpath = vfs_path_from_str (dest);
/* try rename */
if (mc_rename (src_vpath, dest_vpath) == 0)
value = FILE_CONT;
else
{
/* copy + delete */
value =
panel_operate_init_totals (panel, src_vpath, src_stat, ctx,
dialog_type);
if (value == FILE_CONT)
{
if (is_file)
value = move_file_file (tctx, ctx, src, dest);
else
value = move_dir_dir (tctx, ctx, src, dest);
}
}
vfs_path_free (dest_vpath);
break;
}
default:
/* Unknown file operation */
@ -1756,7 +1781,6 @@ operate_single_file (const WPanel * panel, FileOperation operation, file_op_tota
}
}
ret:
vfs_path_free (src_vpath);
return value;