diff --git a/src/csync/csync.cpp b/src/csync/csync.cpp index aa531e18b..0f028731d 100644 --- a/src/csync/csync.cpp +++ b/src/csync/csync.cpp @@ -114,10 +114,6 @@ void csync_init(CSYNC *ctx, const char *db_file) { assert(!(ctx->status & CSYNC_STATUS_INIT)); ctx->status_code = CSYNC_STATUS_OK; - ctx->local.type = LOCAL_REPLICA; - - ctx->remote.type = REMOTE_REPLICA; - SAFE_FREE(ctx->statedb.file); ctx->statedb.file = c_strdup(db_file); @@ -159,7 +155,6 @@ int csync_update(CSYNC *ctx) { /* update detection for local replica */ csync_gettime(&start); ctx->current = LOCAL_REPLICA; - ctx->replica = ctx->local.type; rc = csync_ftw(ctx, ctx->local.uri, csync_walker, MAX_DEPTH); if (rc < 0) { @@ -179,7 +174,6 @@ int csync_update(CSYNC *ctx) { /* update detection for remote replica */ csync_gettime(&start); ctx->current = REMOTE_REPLICA; - ctx->replica = ctx->remote.type; rc = csync_ftw(ctx, "", csync_walker, MAX_DEPTH); if (rc < 0) { @@ -225,7 +219,6 @@ int csync_reconcile(CSYNC *ctx) { } ctx->current = LOCAL_REPLICA; - ctx->replica = ctx->local.type; rc = csync_reconcile_updates(ctx); @@ -246,7 +239,6 @@ int csync_reconcile(CSYNC *ctx) { csync_gettime(&start); ctx->current = REMOTE_REPLICA; - ctx->replica = ctx->remote.type; rc = csync_reconcile_updates(ctx); diff --git a/src/csync/csync_private.h b/src/csync/csync_private.h index aa1ead2ab..3d0c30b6e 100644 --- a/src/csync/csync_private.h +++ b/src/csync/csync_private.h @@ -106,12 +106,10 @@ struct csync_s { struct { char *uri; c_rbtree_t *tree; - enum csync_replica_e type; } local; struct { c_rbtree_t *tree; - enum csync_replica_e type; int read_from_db; const char *root_perms; /* Permission of the root folder. (Since the root folder is not in the db tree, we need to keep a separate entry.) */ } remote; @@ -120,9 +118,6 @@ struct csync_s { /* replica we are currently walking */ enum csync_replica_e current; - /* replica we want to work on */ - enum csync_replica_e replica; - /* Used in the update phase so changes in the sub directories can be notified to parent directories */ csync_file_stat_t *current_fs; diff --git a/src/csync/csync_update.cpp b/src/csync/csync_update.cpp index fab7acd4a..d3cdfab89 100644 --- a/src/csync/csync_update.cpp +++ b/src/csync/csync_update.cpp @@ -660,7 +660,7 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn, } /* Only for the local replica we have to stat(), for the remote one we have all data already */ - if (ctx->replica == LOCAL_REPLICA) { + if (ctx->current == LOCAL_REPLICA) { res = csync_vio_stat(ctx, filename, dirent.get()); } else { res = 0; diff --git a/src/csync/vio/csync_vio.cpp b/src/csync/vio/csync_vio.cpp index cea6b04e1..57eb46c39 100644 --- a/src/csync/vio/csync_vio.cpp +++ b/src/csync/vio/csync_vio.cpp @@ -38,7 +38,7 @@ #include "csync_log.h" csync_vio_handle_t *csync_vio_opendir(CSYNC *ctx, const char *name) { - switch(ctx->replica) { + switch(ctx->current) { case REMOTE_REPLICA: if(ctx->remote.read_from_db) { CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "Read from db flag is true, should not!" ); @@ -47,12 +47,12 @@ csync_vio_handle_t *csync_vio_opendir(CSYNC *ctx, const char *name) { break; case LOCAL_REPLICA: if( ctx->callbacks.update_callback ) { - ctx->callbacks.update_callback(ctx->replica, name, ctx->callbacks.update_callback_userdata); + ctx->callbacks.update_callback(ctx->current, name, ctx->callbacks.update_callback_userdata); } return csync_vio_local_opendir(name); break; default: - CSYNC_LOG(CSYNC_LOG_PRIORITY_ALERT, "Invalid replica (%d)", (int)ctx->replica); + CSYNC_LOG(CSYNC_LOG_PRIORITY_ALERT, "Invalid replica (%d)", (int)ctx->current); break; } return NULL; @@ -66,7 +66,7 @@ int csync_vio_closedir(CSYNC *ctx, csync_vio_handle_t *dhandle) { return -1; } - switch(ctx->replica) { + switch(ctx->current) { case REMOTE_REPLICA: if( ctx->remote.read_from_db ) { CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "Remote ReadFromDb is true, should not!"); @@ -78,14 +78,14 @@ int csync_vio_closedir(CSYNC *ctx, csync_vio_handle_t *dhandle) { rc = csync_vio_local_closedir(dhandle); break; default: - CSYNC_LOG(CSYNC_LOG_PRIORITY_ALERT, "Invalid replica (%d)", (int)ctx->replica); + CSYNC_LOG(CSYNC_LOG_PRIORITY_ALERT, "Invalid replica (%d)", (int)ctx->current); break; } return rc; } std::unique_ptr csync_vio_readdir(CSYNC *ctx, csync_vio_handle_t *dhandle) { - switch(ctx->replica) { + switch(ctx->current) { case REMOTE_REPLICA: if( ctx->remote.read_from_db ) { CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "Remote readfromdb is true, should not!"); @@ -96,7 +96,7 @@ std::unique_ptr csync_vio_readdir(CSYNC *ctx, csync_vio_handl return csync_vio_local_readdir(dhandle); break; default: - CSYNC_LOG(CSYNC_LOG_PRIORITY_ALERT, "Invalid replica (%d)", (int)ctx->replica); + CSYNC_LOG(CSYNC_LOG_PRIORITY_ALERT, "Invalid replica (%d)", (int)ctx->current); break; } @@ -107,10 +107,10 @@ std::unique_ptr csync_vio_readdir(CSYNC *ctx, csync_vio_handl int csync_vio_stat(CSYNC *ctx, const char *uri, csync_file_stat_t *buf) { int rc = -1; - switch(ctx->replica) { + switch(ctx->current) { case REMOTE_REPLICA: CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "ERROR: Cannot call remote stat, not implemented"); - assert(ctx->replica != REMOTE_REPLICA); + assert(ctx->current != REMOTE_REPLICA); break; case LOCAL_REPLICA: rc = csync_vio_local_stat(uri, buf); diff --git a/test/csync/vio_tests/check_vio.cpp b/test/csync/vio_tests/check_vio.cpp index cdb36a6a0..6f4f3a9b4 100644 --- a/test/csync/vio_tests/check_vio.cpp +++ b/test/csync/vio_tests/check_vio.cpp @@ -51,7 +51,7 @@ static int setup(void **state) csync_create(&csync, "/tmp/csync1"); - csync->replica = LOCAL_REPLICA; + csync->current = LOCAL_REPLICA; *state = csync; return 0; diff --git a/test/csync/vio_tests/check_vio_ext.cpp b/test/csync/vio_tests/check_vio_ext.cpp index d93bdef01..faf5804e7 100644 --- a/test/csync/vio_tests/check_vio_ext.cpp +++ b/test/csync/vio_tests/check_vio_ext.cpp @@ -99,7 +99,7 @@ static int setup_testenv(void **state) { csync_create(&(mystate->csync), "/tmp/csync1"); - mystate->csync->replica = LOCAL_REPLICA; + mystate->csync->current = LOCAL_REPLICA; *state = mystate; return 0;