Merge branch '3196_move_file_count'

* 3196_move_file_count:
  Rename structure: FileOpTotalContext -> file_op_total_context_t.
  Ticket #3196: fix incorrect file counting during move operation.
This commit is contained in:
Andrew Borodin 2014-05-04 09:37:51 +04:00
commit 7ce218d942
8 changed files with 37 additions and 27 deletions

View File

@ -560,7 +560,7 @@ do_compute_dir_size (const vfs_path_t * dirname_vpath, void *ui,
/* --------------------------------------------------------------------------------------------- */
static FileProgressStatus
progress_update_one (FileOpTotalContext * tctx, file_op_context_t * ctx, off_t add)
progress_update_one (file_op_total_context_t * tctx, file_op_context_t * ctx, off_t add)
{
struct timeval tv_current;
static struct timeval tv_start = { };
@ -821,7 +821,7 @@ files_error (const char *format, const char *file1, const char *file2)
/* --------------------------------------------------------------------------------------------- */
static void
copy_file_file_display_progress (FileOpTotalContext * tctx, file_op_context_t * ctx,
copy_file_file_display_progress (file_op_total_context_t * tctx, file_op_context_t * ctx,
struct timeval tv_current, struct timeval tv_transfer_start,
off_t file_size, off_t n_read_total)
{
@ -876,7 +876,8 @@ copy_file_file_display_progress (FileOpTotalContext * tctx, file_op_context_t *
/* {{{ Move routines */
static FileProgressStatus
move_file_file (FileOpTotalContext * tctx, file_op_context_t * ctx, const char *s, const char *d)
move_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx, const char *s,
const char *d)
{
struct stat src_stats, dst_stats;
FileProgressStatus return_status = FILE_CONT;
@ -1026,7 +1027,7 @@ move_file_file (FileOpTotalContext * tctx, file_op_context_t * ctx, const char *
/** Don't update progress status if progress_count==NULL */
static FileProgressStatus
erase_file (FileOpTotalContext * tctx, file_op_context_t * ctx, const vfs_path_t * vpath)
erase_file (file_op_total_context_t * tctx, file_op_context_t * ctx, const vfs_path_t * vpath)
{
struct stat buf;
@ -1072,7 +1073,7 @@ erase_file (FileOpTotalContext * tctx, file_op_context_t * ctx, const vfs_path_t
skipall->remove as much as possible
*/
static FileProgressStatus
recursive_erase (FileOpTotalContext * tctx, file_op_context_t * ctx, const vfs_path_t * vpath)
recursive_erase (file_op_total_context_t * tctx, file_op_context_t * ctx, const vfs_path_t * vpath)
{
struct dirent *next;
DIR *reading;
@ -1443,7 +1444,7 @@ end_bg_process (file_op_context_t * ctx, enum OperationMode mode)
/* --------------------------------------------------------------------------------------------- */
FileProgressStatus
copy_file_file (FileOpTotalContext * tctx, file_op_context_t * ctx,
copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
const char *src_path, const char *dst_path)
{
uid_t src_uid = (uid_t) (-1);
@ -1979,7 +1980,7 @@ copy_file_file (FileOpTotalContext * tctx, file_op_context_t * ctx,
function calls */
FileProgressStatus
copy_dir_dir (FileOpTotalContext * tctx, file_op_context_t * ctx, const char *s, const char *d,
copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const char *s, const char *d,
gboolean toplevel, gboolean move_over, gboolean do_delete, GSList * parent_dirs)
{
struct dirent *next;
@ -2249,7 +2250,7 @@ copy_dir_dir (FileOpTotalContext * tctx, file_op_context_t * ctx, const char *s,
/* {{{ Move routines */
FileProgressStatus
move_dir_dir (FileOpTotalContext * tctx, file_op_context_t * ctx, const char *s, const char *d)
move_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const char *s, const char *d)
{
struct stat sbuf, dbuf;
FileProgressStatus return_status;
@ -2350,6 +2351,7 @@ move_dir_dir (FileOpTotalContext * tctx, file_op_context_t * ctx, const char *s,
goto ret;
oktoret:
file_progress_show_source (ctx, NULL);
file_progress_show_target (ctx, NULL);
file_progress_show (ctx, 0, 0, "", FALSE);
return_status = check_progress_buttons (ctx);
@ -2359,6 +2361,9 @@ move_dir_dir (FileOpTotalContext * tctx, file_op_context_t * ctx, const char *s,
mc_refresh ();
if (ctx->erase_at_end)
{
/* Reset progress count before delete to avoid counting files twice */
tctx->progress_count = tctx->prev_progress_count;
while (erase_list != NULL && return_status != FILE_ABORT)
{
struct link *lp = (struct link *) erase_list->data;
@ -2371,6 +2376,9 @@ move_dir_dir (FileOpTotalContext * tctx, file_op_context_t * ctx, const char *s,
erase_list = g_slist_remove (erase_list, lp);
free_link (lp);
}
/* Save progress counter before move next directory */
tctx->prev_progress_count = tctx->progress_count;
}
erase_dir_iff_empty (ctx, src_vpath, tctx->progress_count);
@ -2388,7 +2396,7 @@ move_dir_dir (FileOpTotalContext * tctx, file_op_context_t * ctx, const char *s,
/* {{{ Erase routines */
FileProgressStatus
erase_dir (FileOpTotalContext * tctx, file_op_context_t * ctx, const vfs_path_t * s_vpath)
erase_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const vfs_path_t * s_vpath)
{
FileProgressStatus error;
@ -2589,7 +2597,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
int i;
FileProgressStatus value;
file_op_context_t *ctx;
FileOpTotalContext *tctx;
file_op_total_context_t *tctx;
vfs_path_t *tmp_vpath;
filegui_dialog_type_t dialog_type = FILEGUI_DIALOG_ONE_ITEM;

View File

@ -34,15 +34,15 @@ typedef struct
/*** declarations of public functions ************************************************************/
FileProgressStatus copy_file_file (FileOpTotalContext * tctx, file_op_context_t * ctx,
FileProgressStatus copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
const char *src_path, const char *dst_path);
FileProgressStatus move_dir_dir (FileOpTotalContext * tctx, file_op_context_t * ctx,
FileProgressStatus move_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx,
const char *s, const char *d);
FileProgressStatus copy_dir_dir (FileOpTotalContext * tctx, file_op_context_t * ctx,
FileProgressStatus copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx,
const char *s, const char *d,
gboolean toplevel, gboolean move_over, gboolean do_delete,
GSList * parent_dirs);
FileProgressStatus erase_dir (FileOpTotalContext * tctx, file_op_context_t * ctx,
FileProgressStatus erase_dir (file_op_total_context_t * tctx, file_op_context_t * ctx,
const vfs_path_t * vpath);
gboolean panel_operate (void *source_panel, FileOperation op, gboolean force_single);

View File

@ -944,7 +944,7 @@ file_progress_show_count (file_op_context_t * ctx, size_t done, size_t total)
/* --------------------------------------------------------------------------------------------- */
void
file_progress_show_total (FileOpTotalContext * tctx, file_op_context_t * ctx,
file_progress_show_total (file_op_total_context_t * tctx, file_op_context_t * ctx,
uintmax_t copied_bytes, gboolean show_summary)
{
char buffer[BUF_TINY];
@ -1087,6 +1087,7 @@ file_progress_show_deleting (file_op_context_t * ctx, const char *s, size_t * co
return;
ui = ctx->ui;
label_set_text (ui->src_file_label, _("Deleting"));
label_set_text (ui->src_file, truncFileStringSecure (ui->op_dlg, s));
if (count != NULL)

View File

@ -32,7 +32,7 @@ FileProgressStatus check_progress_buttons (file_op_context_t * ctx);
void file_progress_show (file_op_context_t * ctx, off_t done, off_t total,
const char *stalled_msg, gboolean force_update);
void file_progress_show_count (file_op_context_t * ctx, size_t done, size_t total);
void file_progress_show_total (FileOpTotalContext * tctx, file_op_context_t * ctx,
void file_progress_show_total (file_op_total_context_t * tctx, file_op_context_t * ctx,
uintmax_t copied_bytes, gboolean show_summary);
void file_progress_show_source (file_op_context_t * ctx, const vfs_path_t * s_vpath);
void file_progress_show_target (file_op_context_t * ctx, const vfs_path_t * path);

View File

@ -108,11 +108,11 @@ file_op_context_destroy (file_op_context_t * ctx)
/* --------------------------------------------------------------------------------------------- */
FileOpTotalContext *
file_op_total_context_t *
file_op_total_context_new (void)
{
FileOpTotalContext *tctx;
tctx = g_new0 (FileOpTotalContext, 1);
file_op_total_context_t *tctx;
tctx = g_new0 (file_op_total_context_t, 1);
tctx->ask_overwrite = TRUE;
return tctx;
}
@ -120,7 +120,7 @@ file_op_total_context_new (void)
/* --------------------------------------------------------------------------------------------- */
void
file_op_total_context_destroy (FileOpTotalContext * tctx)
file_op_total_context_destroy (file_op_total_context_t * tctx)
{
g_free (tctx);
}

View File

@ -165,6 +165,7 @@ typedef struct
typedef struct
{
size_t progress_count;
size_t prev_progress_count; /* Used in OP_MOVE between copy and remove directories */
uintmax_t progress_bytes;
uintmax_t copied_bytes;
size_t bps;
@ -173,7 +174,7 @@ typedef struct
double eta_secs;
gboolean ask_overwrite;
} FileOpTotalContext;
} file_op_total_context_t;
/*** global variables defined in .c file *********************************************************/
@ -184,8 +185,8 @@ extern const char *op_names[3];
file_op_context_t *file_op_context_new (FileOperation op);
void file_op_context_destroy (file_op_context_t * ctx);
FileOpTotalContext *file_op_total_context_new (void);
void file_op_total_context_destroy (FileOpTotalContext * tctx);
file_op_total_context_t *file_op_total_context_new (void);
void file_op_total_context_destroy (file_op_total_context_t * tctx);
/* The following functions are implemented separately by each port */
FileProgressStatus file_progress_real_query_replace (file_op_context_t * ctx,

View File

@ -776,7 +776,7 @@ tree_copy (WTree * tree, const char *default_dest)
if (dest != NULL && *dest != '\0')
{
file_op_context_t *ctx;
FileOpTotalContext *tctx;
file_op_total_context_t *tctx;
ctx = file_op_context_new (OP_COPY);
tctx = file_op_total_context_new ();
@ -800,7 +800,7 @@ tree_move (WTree * tree, const char *default_dest)
char *dest;
struct stat buf;
file_op_context_t *ctx;
FileOpTotalContext *tctx;
file_op_total_context_t *tctx;
if (tree->selected_ptr == NULL)
return;
@ -865,7 +865,7 @@ tree_rmdir (void *data)
{
WTree *tree = data;
file_op_context_t *ctx;
FileOpTotalContext *tctx;
file_op_total_context_t *tctx;
if (!tree->selected_ptr)
return;

View File

@ -55,7 +55,7 @@ check_for_default (const vfs_path_t * default_file_vpath, const vfs_path_t * fil
if (!exist_file (vfs_path_as_str (file_vpath)))
{
file_op_context_t *ctx;
FileOpTotalContext *tctx;
file_op_total_context_t *tctx;
if (!exist_file (vfs_path_as_str (default_file_vpath)))
return FALSE;