mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-28 11:48:56 +03:00
Do not fetch folder id after propagation.
Delay that for the next sync.
(cherry picked from commit 1eb534dd53
)
This commit is contained in:
parent
b99677f985
commit
b4ec9f887c
4 changed files with 0 additions and 214 deletions
25
src/csync.c
25
src/csync.c
|
@ -536,29 +536,6 @@ int csync_propagate(CSYNC *ctx) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
csync_gettime(&start);
|
||||
ctx->current = LOCAL_REPLICA;
|
||||
ctx->replica = ctx->local.type;
|
||||
rc = csync_correct_id(ctx);
|
||||
if (rc < 0) {
|
||||
ctx->error_code = CSYNC_ERR_PROPAGATE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctx->current = REMOTE_REPLICA;
|
||||
ctx->replica = ctx->remote.type;
|
||||
rc = csync_correct_id(ctx);
|
||||
if (rc < 0) {
|
||||
ctx->error_code = CSYNC_ERR_PROPAGATE;
|
||||
return -1;
|
||||
}
|
||||
csync_gettime(&finish);
|
||||
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG,
|
||||
"Correct Id took. %.2f seconds ",
|
||||
c_secdiff(finish, start));
|
||||
|
||||
|
||||
ctx->status |= CSYNC_STATUS_PROPAGATE;
|
||||
|
||||
return 0;
|
||||
|
@ -770,10 +747,8 @@ int csync_destroy(CSYNC *ctx) {
|
|||
/* free memory */
|
||||
c_rbtree_free(ctx->local.tree);
|
||||
c_list_free(ctx->local.list);
|
||||
c_list_free(ctx->local.id_list);
|
||||
c_rbtree_free(ctx->remote.tree);
|
||||
c_list_free(ctx->remote.list);
|
||||
c_list_free(ctx->remote.id_list);
|
||||
SAFE_FREE(ctx->local.uri);
|
||||
SAFE_FREE(ctx->remote.uri);
|
||||
SAFE_FREE(ctx->options.config_dir);
|
||||
|
|
|
@ -113,7 +113,6 @@ struct csync_s {
|
|||
char *uri;
|
||||
c_rbtree_t *tree;
|
||||
c_list_t *list;
|
||||
c_list_t *id_list;
|
||||
enum csync_replica_e type;
|
||||
int read_from_db;
|
||||
} remote;
|
||||
|
|
|
@ -57,28 +57,6 @@ static int _csync_cleanup_cmp(const void *a, const void *b) {
|
|||
return strcmp(st_a->path, st_b->path);
|
||||
}
|
||||
|
||||
static void _store_id_update(CSYNC *ctx, csync_file_stat_t *st) {
|
||||
c_list_t *list = NULL;
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "SYNCED remember dir: %s", st->path);
|
||||
|
||||
switch (ctx->current) {
|
||||
case LOCAL_REPLICA:
|
||||
list = c_list_prepend(ctx->local.id_list, (void*)st);
|
||||
if( list != NULL ) {
|
||||
ctx->local.id_list = list;
|
||||
}
|
||||
break;
|
||||
case REMOTE_REPLICA:
|
||||
list = c_list_prepend(ctx->remote.id_list, (void*)st);
|
||||
if(list != NULL ) {
|
||||
ctx->remote.id_list = list;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Record the error in the ctx->progress
|
||||
pi may be a previous csync_progressinfo_t from the database.
|
||||
If pi is NULL, a new one is created, else it is re-used
|
||||
|
@ -551,9 +529,6 @@ static int _csync_push_file(CSYNC *ctx, csync_file_stat_t *st) {
|
|||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "PUSHED file: %s", duri);
|
||||
|
||||
rc = 0;
|
||||
if (ctx->current == LOCAL_REPLICA) {
|
||||
_store_id_update(ctx, st);
|
||||
}
|
||||
|
||||
out:
|
||||
ctx->replica = srep;
|
||||
|
@ -835,10 +810,6 @@ static int _csync_rename_file(CSYNC *ctx, csync_file_stat_t *st) {
|
|||
}
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "RENAME file: %s => %s with ID %s", st->path, st->destpath, st->md5);
|
||||
|
||||
if (ctx->current == REMOTE_REPLICA) {
|
||||
_store_id_update(ctx, st);
|
||||
}
|
||||
|
||||
out:
|
||||
SAFE_FREE(suri);
|
||||
SAFE_FREE(duri);
|
||||
|
@ -933,11 +904,6 @@ static int _csync_remove_file(CSYNC *ctx, csync_file_stat_t *st) {
|
|||
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "REMOVED file: %s", uri);
|
||||
|
||||
if (ctx->current == REMOTE_REPLICA) {
|
||||
_store_id_update(ctx, st);
|
||||
}
|
||||
|
||||
|
||||
rc = 0;
|
||||
out:
|
||||
SAFE_FREE(uri);
|
||||
|
@ -1036,10 +1002,6 @@ static int _csync_new_dir(CSYNC *ctx, csync_file_stat_t *st) {
|
|||
|
||||
csync_vio_utimes(ctx, uri, times);
|
||||
|
||||
if (ctx->replica == REMOTE_REPLICA) {
|
||||
_store_id_update(ctx, st);
|
||||
}
|
||||
|
||||
/* set instruction for the statedb merger */
|
||||
st->instruction = CSYNC_INSTRUCTION_UPDATED;
|
||||
|
||||
|
@ -1126,9 +1088,6 @@ static int _csync_sync_dir(CSYNC *ctx, csync_file_stat_t *st) {
|
|||
times[0].tv_usec = times[1].tv_usec = 0;
|
||||
|
||||
csync_vio_utimes(ctx, uri, times);
|
||||
if (ctx->replica == REMOTE_REPLICA) {
|
||||
_store_id_update(ctx, st);
|
||||
}
|
||||
/* set instruction for the statedb merger */
|
||||
st->instruction = CSYNC_INSTRUCTION_UPDATED;
|
||||
|
||||
|
@ -1262,151 +1221,6 @@ static int _cmp_char( const void *d1, const void *d2 )
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Internal helper method for _csync_correct_id */
|
||||
static void _csync_correct_id_helper(CSYNC *ctx, char *path, c_list_t **seen_dirs, c_rbtree_t *tree)
|
||||
{
|
||||
while( path ) {
|
||||
uint64_t h;
|
||||
int len;
|
||||
c_rbnode_t *node = NULL;
|
||||
|
||||
char *old_path = path;
|
||||
csync_file_stat_t *tfs = NULL;
|
||||
|
||||
/* do stuff with the dir here */
|
||||
|
||||
if( *seen_dirs && c_list_find_custom( *seen_dirs, path, _cmp_char)) {
|
||||
// CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "saw this dir already: %s", path);
|
||||
} else {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "climb on dir: %s", path);
|
||||
*seen_dirs = c_list_prepend( *seen_dirs, c_strdup(path));
|
||||
|
||||
/* Find the correct target entry. */
|
||||
len = strlen(path);
|
||||
h = c_jhash64((uint8_t *) path, len, 0);
|
||||
|
||||
node = c_rbtree_find(tree, &h);
|
||||
if (node == NULL) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Unable to find node");
|
||||
} else {
|
||||
tfs = c_rbtree_node_data(node);
|
||||
if( tfs ) {
|
||||
if(tfs->instruction == CSYNC_INSTRUCTION_DELETED) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Skipping update of MD5 because item is deleted.");
|
||||
} else {
|
||||
if(tfs->md5) SAFE_FREE(tfs->md5);
|
||||
tfs->md5 = _get_md5(ctx, path);
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "MD5 for dir: %s %s (Instruction: %s)", tfs->path,
|
||||
tfs->md5, csync_instruction_str(tfs->instruction));
|
||||
if( tfs->md5 && tfs->instruction == CSYNC_INSTRUCTION_NONE ) {
|
||||
/* set instruction for the statedb merger */
|
||||
tfs->instruction = CSYNC_INSTRUCTION_UPDATED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* get the parent dir */
|
||||
path = c_dirname( path );
|
||||
/* free the old path memory */
|
||||
SAFE_FREE(old_path );
|
||||
|
||||
/* exit on top directory */
|
||||
if( c_streq(path, ".")) {
|
||||
SAFE_FREE(path);
|
||||
path = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function corrects the unique IDs of parent directories of changed
|
||||
* files. Other than in the file system, the change of a unique Id propagates
|
||||
* up to the top dir. To save the correct IDs, in all propagations, pathes
|
||||
* are recorded in the local and remotes id_list lists.
|
||||
* In this function, the unique ID is queried for each directory once and
|
||||
* stored into the according entry.
|
||||
*/
|
||||
int csync_correct_id(CSYNC *ctx) {
|
||||
c_list_t *walk = NULL;
|
||||
c_list_t *seen_dirs = NULL;
|
||||
c_list_t *list = NULL;
|
||||
c_rbtree_t *tree = NULL;
|
||||
char *path = NULL;
|
||||
|
||||
switch (ctx->current) {
|
||||
case LOCAL_REPLICA:
|
||||
list = ctx->local.id_list;
|
||||
tree = ctx->local.tree;
|
||||
break;
|
||||
case REMOTE_REPLICA:
|
||||
list = ctx->remote.id_list;
|
||||
tree = ctx->remote.tree;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (list == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
list = c_list_sort(list, _csync_cleanup_cmp);
|
||||
if (list == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (walk = c_list_last(list); walk != NULL; walk = c_list_prev(walk)) {
|
||||
csync_file_stat_t *st = NULL;
|
||||
|
||||
st = (csync_file_stat_t *) walk->data;
|
||||
if( st->type == CSYNC_FTW_TYPE_FILE ) {
|
||||
path = c_dirname( st->path );
|
||||
} else if( st->type == CSYNC_FTW_TYPE_DIR ) {
|
||||
path = c_strdup(st->path); /* Allocate mem for this not to disappoint FREE */
|
||||
} else {
|
||||
/* unhandled path */
|
||||
}
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "correct ID on dir: %s", path);
|
||||
|
||||
/* handle the . path */
|
||||
if( path && path[0] == '.' && strlen(path) == 1) {
|
||||
SAFE_FREE(path);
|
||||
path = NULL;
|
||||
}
|
||||
|
||||
_csync_correct_id_helper(ctx, path, &seen_dirs, tree);
|
||||
|
||||
if (st->type == CSYNC_FTW_TYPE_FILE && ctx->current == REMOTE_REPLICA
|
||||
&& st->destpath) {
|
||||
path = c_dirname( st->destpath );
|
||||
if( path && path[0] == '.' && strlen(path) == 1) {
|
||||
SAFE_FREE(path);
|
||||
path = NULL;
|
||||
}
|
||||
_csync_correct_id_helper(ctx, path, &seen_dirs, ctx->local.tree);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Free the seen_dirs list */
|
||||
|
||||
if( seen_dirs ) {
|
||||
c_list_t *walk1 = NULL;
|
||||
|
||||
for (walk1 = c_list_first(seen_dirs); walk1 != NULL; walk1 = c_list_next(walk1)) {
|
||||
char *data = NULL;
|
||||
|
||||
data = (char*) walk1->data;
|
||||
SAFE_FREE(data);
|
||||
}
|
||||
}
|
||||
c_list_free(seen_dirs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _csync_propagation_cleanup(CSYNC *ctx) {
|
||||
c_list_t *list = NULL;
|
||||
c_list_t *walk = NULL;
|
||||
|
|
|
@ -65,8 +65,6 @@
|
|||
*/
|
||||
int csync_propagate_files(CSYNC *ctx);
|
||||
|
||||
|
||||
int csync_correct_id(CSYNC *ctx);
|
||||
int csync_propagate_rename_file(CSYNC *ctx, csync_file_stat_t *st);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue