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);
/* 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) {
/* 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) {
}
ctx->current = LOCAL_REPLICA;
- ctx->replica = ctx->local.type;
rc = csync_reconcile_updates(ctx);
csync_gettime(&start);
ctx->current = REMOTE_REPLICA;
- ctx->replica = ctx->remote.type;
rc = csync_reconcile_updates(ctx);
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;
/* 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;
}
/* 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;
#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!" );
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;
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!");
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_file_stat_t> 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!");
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;
}
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);
csync_create(&csync, "/tmp/csync1");
- csync->replica = LOCAL_REPLICA;
+ csync->current = LOCAL_REPLICA;
*state = csync;
return 0;
csync_create(&(mystate->csync), "/tmp/csync1");
- mystate->csync->replica = LOCAL_REPLICA;
+ mystate->csync->current = LOCAL_REPLICA;
*state = mystate;
return 0;