mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Base overall progress data on both trees not just one
This commit is contained in:
parent
a12782dccf
commit
917cc7faab
@ -525,6 +525,13 @@ int csync_propagate(CSYNC *ctx) {
|
||||
}
|
||||
ctx->error_code = CSYNC_ERR_NONE;
|
||||
|
||||
rc = csync_init_overall_progress(ctx);
|
||||
if (rc < 0) {
|
||||
if( ctx->error_code == CSYNC_ERR_NONE )
|
||||
ctx->error_code = csync_errno_to_csync_error( CSYNC_ERR_PROPAGATE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctx->current = REMOTE_REPLICA;
|
||||
ctx->replica = ctx->remote.type;
|
||||
rc = csync_propagate_renames(ctx);
|
||||
|
||||
@ -659,7 +659,7 @@ start_fd_based:
|
||||
/* Notify the overall progress */
|
||||
if (ctx->callbacks.overall_progress_cb) {
|
||||
ctx->progress.byte_current += st->size;
|
||||
ctx->callbacks.overall_progress_cb(duri, ++ctx->progress.current_file_no, ctx->progress.file_count,
|
||||
ctx->callbacks.overall_progress_cb(duri, ctx->progress.current_file_no++, ctx->progress.file_count,
|
||||
ctx->progress.byte_current, ctx->progress.byte_sum,
|
||||
ctx->callbacks.userdata);
|
||||
}
|
||||
@ -1631,6 +1631,44 @@ int csync_propagate_rename_file(CSYNC *ctx, csync_file_stat_t *st) {
|
||||
return _csync_rename_file(ctx, st);
|
||||
}
|
||||
|
||||
/* Count the files to transmit for both up- and download, ie. in both replicas. */
|
||||
int csync_init_overall_progress(CSYNC *ctx) {
|
||||
|
||||
if (ctx == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ctx->callbacks.overall_progress_cb == NULL) {
|
||||
/* No progress callback, no need to count */
|
||||
return 0;
|
||||
}
|
||||
|
||||
ctx->current = REMOTE_REPLICA;
|
||||
ctx->replica = ctx->remote.type;
|
||||
|
||||
if (c_rbtree_walk(ctx->remote.tree, (void *) ctx, _csync_propagation_file_count_visitor) < 0) {
|
||||
ctx->error_code = CSYNC_ERR_TREE;
|
||||
return -1;
|
||||
}
|
||||
ctx->current = LOCAL_REPLICA;
|
||||
ctx->replica = ctx->local.type;
|
||||
|
||||
if (c_rbtree_walk(ctx->local.tree, (void *) ctx, _csync_propagation_file_count_visitor) < 0) {
|
||||
ctx->error_code = CSYNC_ERR_TREE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Notify the overall progress */
|
||||
if (ctx->progress.file_count >0) {
|
||||
ctx->progress.current_file_no = 1; /* start with file 1 */
|
||||
}
|
||||
ctx->callbacks.overall_progress_cb("", ctx->progress.current_file_no, ctx->progress.file_count,
|
||||
ctx->progress.byte_current, ctx->progress.byte_sum,
|
||||
ctx->callbacks.userdata);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int csync_propagate_files(CSYNC *ctx) {
|
||||
c_rbtree_t *tree = NULL;
|
||||
|
||||
@ -1645,17 +1683,6 @@ int csync_propagate_files(CSYNC *ctx) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* If there is a overall progress callback set, count the number of files first. */
|
||||
if (ctx->callbacks.overall_progress_cb) {
|
||||
if (c_rbtree_walk(tree, (void *) ctx, _csync_propagation_file_count_visitor) < 0) {
|
||||
return -1;
|
||||
}
|
||||
/* Notify the overall progress */
|
||||
ctx->callbacks.overall_progress_cb("", ctx->progress.current_file_no, ctx->progress.file_count,
|
||||
ctx->progress.byte_current, ctx->progress.byte_sum,
|
||||
ctx->callbacks.userdata);
|
||||
}
|
||||
|
||||
if (c_rbtree_walk(tree, (void *) ctx, _csync_propagation_file_visitor) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -66,6 +66,9 @@
|
||||
int csync_propagate_files(CSYNC *ctx);
|
||||
|
||||
int csync_propagate_rename_file(CSYNC *ctx, csync_file_stat_t *st);
|
||||
|
||||
int csync_init_overall_progress(CSYNC *ctx);
|
||||
|
||||
/**
|
||||
* }@
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user