Optimize restoring of the remote tree from database.

If the etag of a directory hasn't changed, the content for the csync
tree can be restored from database. The code doing that is now optimized
so that this does not take so long any more.
This commit is contained in:
Klaas Freitag 2014-02-07 11:52:37 +01:00
parent 41a4f1fc37
commit 3649869650
7 changed files with 176 additions and 409 deletions

View file

@ -57,7 +57,6 @@ set(csync_SRCS
csync_exclude.c csync_exclude.c
csync_log.c csync_log.c
csync_statedb.c csync_statedb.c
csync_dbtree.c
csync_time.c csync_time.c
csync_util.c csync_util.c
csync_misc.c csync_misc.c

View file

@ -1,235 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2012 by Klaas Freitag <freitag@owncloud.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config_csync.h"
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include "csync_dbtree.h"
#include "c_lib.h"
#include "csync_private.h"
#include "csync_statedb.h"
#include "csync_util.h"
#include "c_macro.h"
#define CSYNC_LOG_CATEGORY_NAME "csync.dbtree"
#include "csync_log.h"
struct dir_listing {
c_list_t *list;
unsigned int cnt;
c_list_t *entry;
char *dir;
};
csync_vio_method_handle_t *csync_dbtree_opendir(CSYNC *ctx, const char *name)
{
char *column = NULL;
const char *path = NULL;
csync_vio_file_stat_t *fs = NULL;
unsigned int c = 0;
c_strlist_t *list = NULL;
struct dir_listing *listing = NULL;
/* "phash INTEGER(8),"
"pathlen INTEGER,"
"path VARCHAR(4096),"
"inode INTEGER,"
"uid INTEGER,"
"gid INTEGER,"
"mode INTEGER,"
"modtime INTEGER(8),"
"type INTEGER,"
"md5 VARCHAR(32)," // That's the etag
*/
int col_count = 10;
if( strlen(name) < strlen(ctx->remote.uri)+1) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "name does not contain remote uri!");
return NULL;
}
path = name + strlen(ctx->remote.uri)+1;
list = csync_statedb_get_below_path(ctx, path);
if( ! list ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Query result list is NULL!");
return NULL;
}
/* list count must be a multiple of col_count */
if( list->count % col_count != 0 ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Wrong size of query result list");
c_strlist_destroy( list );
return NULL;
}
listing = c_malloc(sizeof(struct dir_listing));
ZERO_STRUCTP(listing);
if( listing == NULL ) {
c_strlist_destroy( list );
errno = ENOMEM;
return NULL;
}
listing->dir = c_strdup(path);
for( c = 0; c < (list->count / col_count); c++) {
int base = c*col_count;
int cnt = 0;
int tpath_len = 0;
int type = 0;
char *tpath = list->vector[base+1];
/* check if the result points to a file directly below the search path
* by checking if there is another / in the result.
* If yes, skip it.
* FIXME: Find a better filter solution here.
*/
tpath += strlen(path)+1; /* jump over the search path */
tpath_len = strlen( tpath );
while( cnt < tpath_len ) {
if(*(tpath+cnt) == '/') {
/* CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Skipping entry: %s", list->vector[base+1]); */
break;
}
cnt++;
}
if( cnt < tpath_len ) continue;
if (!list->vector[base+8][0])
continue; /* If etag is empty, the file was removed on the server */
fs = csync_vio_file_stat_new();
fs->fields = CSYNC_VIO_FILE_STAT_FIELDS_NONE;
column = list->vector[base+0]; /* phash */
column = list->vector[base+1]; /* path */
fs->name = c_strdup(column+strlen(path)+1);
column = list->vector[base+2]; /* inode */
fs->inode = atoll(column);
fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_INODE;
column = list->vector[base+3]; /* uid */
fs->uid = atoi(column);
fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_UID;
column = list->vector[base+4]; /* gid */
fs->gid = atoi(column);
fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_GID;
column = list->vector[base+5]; /* mode */
fs->mode = atoi(column);
// fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_M;
column = list->vector[base+6]; /* modtime */
fs->mtime = strtoul(column, NULL, 10);
fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_MTIME;
column = list->vector[base+7]; /* type */
type = atoi(column);
/* Attention: the type of csync_ftw_type_e which is the source for
* the database entry is different from csync_vio_file_type_e which
* is the target file type here. Mapping is needed!
*/
switch( type ) {
case CSYNC_FTW_TYPE_DIR:
fs->type = CSYNC_VIO_FILE_TYPE_DIRECTORY;
break;
case CSYNC_FTW_TYPE_FILE:
fs->type = CSYNC_VIO_FILE_TYPE_REGULAR;
break;
case CSYNC_FTW_TYPE_SLINK:
fs->type = CSYNC_VIO_FILE_TYPE_SYMBOLIC_LINK;
break;
default:
fs->type = CSYNC_VIO_FILE_TYPE_UNKNOWN;
}
fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_TYPE;
column = list->vector[base+8]; /* etag */
fs->etag = c_strdup(column);
fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_ETAG;
column = list->vector[base+9]; /* file id */
csync_vio_file_stat_set_file_id(fs, column);
/* store into result list. */
listing->list = c_list_append( listing->list, fs );
listing->cnt++;
}
if(listing->cnt)
listing->entry = c_list_first( listing->list );
c_strlist_destroy( list );
return listing;
}
int csync_dbtree_closedir(CSYNC *ctx, csync_vio_method_handle_t *dhandle)
{
struct dir_listing *dl = NULL;
int rc = 0;
(void) ctx;
if( dhandle != NULL ) {
dl = (struct dir_listing*) dhandle;
c_list_free(dl->list);
SAFE_FREE(dl->dir);
SAFE_FREE(dl);
}
return rc;
}
csync_vio_file_stat_t *csync_dbtree_readdir(CSYNC *ctx, csync_vio_method_handle_t *dhandle)
{
csync_vio_file_stat_t *fs = NULL;
struct dir_listing *dl = NULL;
(void) ctx;
if( dhandle != NULL ) {
dl = (struct dir_listing*) dhandle;
if( dl->entry != NULL ) {
fs = (csync_vio_file_stat_t*) dl->entry->data;
dl->entry = c_list_next( dl->entry);
}
}
return fs;
}
/* vim: set ts=8 sw=2 et cindent: */

View file

@ -1,60 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2012 by Klaas Freitag <freitag@owncloud.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file csync_dbtree.h
*
* @brief Private interface of csync
*
* @defgroup csyncdbtreeInternals csync statedb internals
* @ingroup csyncInternalAPI
*
* @{
*/
#ifndef _CSYNC_DBTREE_H
#define _CSYNC_DBTREE_H
#include "c_lib.h"
#include "csync_private.h"
#include "vio/csync_vio_handle.h"
/**
* @brief Open a directory based on the statedb.
*
* This function reads the list of files within a directory from statedb and
* builds up a list in memory.
*
* @param ctx The csync context.
* @param name The directory name.
*
* @return 0 on success, less than 0 if an error occured with errno set.
*/
csync_vio_method_handle_t *csync_dbtree_opendir(CSYNC *ctx, const char *name);
int csync_dbtree_closedir(CSYNC *ctx, csync_vio_method_handle_t *dhandle);
csync_vio_file_stat_t *csync_dbtree_readdir(CSYNC *ctx, csync_vio_method_handle_t *dhandle);
/**
* }@
*/
#endif /* _CSYNC_DBTREE_H */
/* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */

View file

@ -190,6 +190,16 @@ static int _csync_statedb_is_empty(sqlite3 *db) {
return rc; return rc;
} }
#ifndef NDEBUG
static void sqlite_profile( void *x, const char* sql, sqlite3_uint64 time)
{
(void)x;
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG,
"_SQL_ %s: %llu", sql, time);
}
#endif
int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb) { int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb) {
int rc = -1; int rc = -1;
int check_rc = -1; int check_rc = -1;
@ -255,6 +265,9 @@ int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb) {
result = csync_statedb_query(db, "PRAGMA case_sensitive_like = ON;"); result = csync_statedb_query(db, "PRAGMA case_sensitive_like = ON;");
c_strlist_destroy(result); c_strlist_destroy(result);
#ifndef NDEBUG
sqlite3_profile(db, sqlite_profile, 0 );
#endif
*pdb = db; *pdb = db;
return 0; return 0;
@ -329,13 +342,67 @@ int csync_statedb_close(const char *statedb, sqlite3 *db, int jwritten) {
return rc; return rc;
} }
// This funciton parses a line from the metadata table into the given csync_file_stat
// structure which it is also allocating.
// Note that this function calls laso sqlite3_step to actually get the info from db and
// returns the sqlite return type.
static int _csync_file_stat_from_metadata_table( csync_file_stat_t **st, sqlite3_stmt *stmt )
{
int rc = SQLITE_ERROR;
int column_count;
int len;
if( ! stmt ) return -1;
column_count = sqlite3_column_count(stmt);
rc = sqlite3_step(stmt);
if( rc == SQLITE_ROW ) {
if(column_count > 7) {
const char *name;
/* phash, pathlen, path, inode, uid, gid, mode, modtime */
len = sqlite3_column_int(stmt, 1);
*st = c_malloc(sizeof(csync_file_stat_t) + len + 1);
if (*st == NULL) {
return -1;
}
/* clear the whole structure */
ZERO_STRUCTP(*st);
/* The query suceeded so use the phash we pass to the function. */
(*st)->phash = sqlite3_column_int64(stmt, 0);
(*st)->pathlen = sqlite3_column_int(stmt, 1);
name = (const char*) sqlite3_column_text(stmt, 2);
memcpy((*st)->path, (len ? name : ""), len + 1);
(*st)->inode = sqlite3_column_int64(stmt,3);
(*st)->uid = sqlite3_column_int(stmt, 4);
(*st)->gid = sqlite3_column_int(stmt, 5);
(*st)->mode = sqlite3_column_int(stmt, 6);
(*st)->modtime = strtoul((char*)sqlite3_column_text(stmt, 7), NULL, 10);
if(*st && column_count > 8 ) {
(*st)->type = sqlite3_column_int(stmt, 8);
}
if(column_count > 9 && sqlite3_column_text(stmt, 9)) {
(*st)->etag = c_strdup( (char*) sqlite3_column_text(stmt, 9) );
}
if(column_count > 10 && sqlite3_column_text(stmt,10)) {
csync_vio_set_file_id((*st)->file_id, (char*) sqlite3_column_text(stmt, 10));
}
}
}
return rc;
}
/* caller must free the memory */ /* caller must free the memory */
csync_file_stat_t *csync_statedb_get_stat_by_hash(sqlite3 *db, csync_file_stat_t *csync_statedb_get_stat_by_hash(sqlite3 *db,
uint64_t phash) uint64_t phash)
{ {
csync_file_stat_t *st = NULL; csync_file_stat_t *st = NULL;
size_t len = 0;
int column_count = 0;
int rc; int rc;
if( _by_hash_stmt == NULL ) { if( _by_hash_stmt == NULL ) {
@ -350,64 +417,11 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(sqlite3 *db,
return NULL; return NULL;
} }
column_count = sqlite3_column_count(_by_hash_stmt);
sqlite3_bind_int64(_by_hash_stmt, 1, (long long signed int)phash); sqlite3_bind_int64(_by_hash_stmt, 1, (long long signed int)phash);
rc = sqlite3_step(_by_hash_stmt);
if( rc == SQLITE_ROW ) { if( _csync_file_stat_from_metadata_table(&st, _by_hash_stmt) < 0 ) {
if(column_count > 7) { CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Could not get line from metadata!");
/* phash, pathlen, path, inode, uid, gid, mode, modtime */
len = sqlite3_column_int(_by_hash_stmt, 1);
st = c_malloc(sizeof(csync_file_stat_t) + len + 1);
if (st == NULL) {
return NULL;
}
/* clear the whole structure */
ZERO_STRUCTP(st);
/*
* FIXME:
* We use an INTEGER(8) which is signed to the phash in the sqlite3 db,
* but the phash is an uint64_t. So for some values we get a string like
* "1.66514565505016e+19". For such a string strtoull() returns 1.
* phash = 1
*
* st->phash = strtoull(result->vector[0], NULL, 10);
*/
/* The query suceeded so use the phash we pass to the function. */
st->phash = phash;
st->pathlen = sqlite3_column_int(_by_hash_stmt, 1);
memcpy(st->path, (len ? (char*) sqlite3_column_text(_by_hash_stmt, 2) : ""), len + 1);
st->inode = sqlite3_column_int64(_by_hash_stmt,3);
st->uid = sqlite3_column_int(_by_hash_stmt, 4);
st->gid = sqlite3_column_int(_by_hash_stmt, 5);
st->mode = sqlite3_column_int(_by_hash_stmt, 6);
st->modtime = strtoul((char*)sqlite3_column_text(_by_hash_stmt, 7), NULL, 10);
if(st && column_count > 8 ) {
st->type = sqlite3_column_int(_by_hash_stmt, 8);
}
if(column_count > 9 && sqlite3_column_text(_by_hash_stmt, 9)) {
st->etag = c_strdup( (char*) sqlite3_column_text(_by_hash_stmt, 9) );
}
if(column_count > 10 && sqlite3_column_text(_by_hash_stmt,10)) {
csync_vio_set_file_id(st->file_id, (char*) sqlite3_column_text(_by_hash_stmt, 10));
}
}
} else {
/* SQLITE_DONE says there is no further row. That's not an error. */
if (rc != SQLITE_DONE) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "sqlite hash query fail: %s", sqlite3_errmsg(db));
}
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "No result record found for phash = %llu",
(long long unsigned int) phash);
SAFE_FREE(st);
} }
sqlite3_reset(_by_hash_stmt); sqlite3_reset(_by_hash_stmt);
return st; return st;
@ -559,23 +573,63 @@ char *csync_statedb_get_uniqId( CSYNC *ctx, uint64_t jHash, csync_vio_file_stat_
return ret; return ret;
} }
c_strlist_t *csync_statedb_get_below_path( CSYNC *ctx, const char *path ) { #define BELOW_PATH_QUERY "SELECT phash, pathlen, path, inode, uid, gid, mode, modtime, type, md5, fileid FROM metadata WHERE path LIKE(?)"
c_strlist_t *list = NULL;
char *stmt = NULL;
stmt = sqlite3_mprintf("SELECT phash, path, inode, uid, gid, mode, modtime, type, md5, fileid " int csync_statedb_get_below_path( CSYNC *ctx, const char *path ) {
"FROM metadata WHERE path LIKE('%q/%%')", path); int rc;
if (stmt == NULL) { sqlite3_stmt *stmt = NULL;
return NULL; int64_t cnt = 0;
char *likepath;
int asp;
if( !path ) {
return -1;
} }
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "SQL: %s", stmt); rc = sqlite3_prepare_v2(ctx->statedb.db, BELOW_PATH_QUERY, -1, &stmt, NULL);
if( rc != SQLITE_OK ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Unable to create stmt for hash query.");
return -1;
}
list = csync_statedb_query( ctx->statedb.db, stmt ); if (stmt == NULL) {
return -1;
}
sqlite3_free(stmt); asp = asprintf( &likepath, "%s/%%%%", path);
if (asp < 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "asprintf failed!");
return -1;
}
return list; sqlite3_bind_text(stmt, 1, likepath, -1, SQLITE_STATIC);
cnt = 0;
do {
csync_file_stat_t *st = NULL;
rc = _csync_file_stat_from_metadata_table( &st, stmt);
if( st ) {
/* store into result list. */
if (c_rbtree_insert(ctx->remote.tree, (void *) st) < 0) {
SAFE_FREE(st);
ctx->status_code = CSYNC_STATUS_TREE_ERROR;
break;
}
cnt++;
}
} while( rc == SQLITE_ROW );
if( rc != SQLITE_DONE ) {
ctx->status_code = CSYNC_STATUS_TREE_ERROR;
} else {
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "%ld entries read below path %s from db.", cnt, path);
}
sqlite3_finalize(stmt);
SAFE_FREE(likepath);
return 0;
} }
/* query the statedb, caller must free the memory */ /* query the statedb, caller must free the memory */

View file

@ -82,7 +82,7 @@ char *csync_statedb_get_uniqId(CSYNC *ctx, uint64_t jHash, csync_vio_file_stat_t
* *
* @return A stringlist containing a multiple of 9 entries. * @return A stringlist containing a multiple of 9 entries.
*/ */
c_strlist_t *csync_statedb_get_below_path(CSYNC *ctx, const char *path); int csync_statedb_get_below_path(CSYNC *ctx, const char *path);
/** /**
* @brief A generic statedb query. * @brief A generic statedb query.

View file

@ -423,6 +423,22 @@ int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs,
return rc; return rc;
} }
static void fill_tree_from_db(CSYNC *ctx, const char *uri)
{
const char *path = NULL;
if( strlen(uri) < strlen(ctx->remote.uri)+1) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "name does not contain remote uri!");
return;
}
path = uri + strlen(ctx->remote.uri)+1;
if( csync_statedb_get_below_path(ctx, path) < 0 ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "StateDB could not be read!");
}
}
/* File tree walker */ /* File tree walker */
int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn, int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
unsigned int depth) { unsigned int depth) {
@ -447,24 +463,31 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
read_from_db = ctx->remote.read_from_db; read_from_db = ctx->remote.read_from_db;
// if the etag of this dir is still the same, its content is restored from the
// database.
if( do_read_from_db ) {
fill_tree_from_db(ctx, uri);
goto done;
}
if ((dh = csync_vio_opendir(ctx, uri)) == NULL) { if ((dh = csync_vio_opendir(ctx, uri)) == NULL) {
int asp = 0; int asp = 0;
/* permission denied */ /* permission denied */
ctx->status_code = csync_errno_to_status(errno, CSYNC_STATUS_OPENDIR_ERROR); ctx->status_code = csync_errno_to_status(errno, CSYNC_STATUS_OPENDIR_ERROR);
if (errno == EACCES) { if (errno == EACCES) {
return 0; return 0;
} else if(errno == ENOENT) { } else if(errno == ENOENT) {
asp = asprintf( &ctx->error_string, "%s", uri); asp = asprintf( &ctx->error_string, "%s", uri);
if (asp < 0) { if (asp < 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "asprintf failed!"); CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "asprintf failed!");
}
} else {
C_STRERROR(errno, errbuf, sizeof(errbuf));
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR,
"opendir failed for %s - %s (errno %d)",
uri, errbuf, errno);
} }
} else { goto error;
C_STRERROR(errno, errbuf, sizeof(errbuf));
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR,
"opendir failed for %s - %s (errno %d)",
uri, errbuf, errno);
}
goto error;
} }
while ((dirent = csync_vio_readdir(ctx, dh))) { while ((dirent = csync_vio_readdir(ctx, dh))) {
@ -528,13 +551,8 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
} }
/* == see if really stat has to be called. */ /* == see if really stat has to be called. */
if( do_read_from_db ) { fs = csync_vio_file_stat_new();
fs = dirent; res = csync_vio_stat(ctx, filename, fs);
res = 0;
} else {
fs = csync_vio_file_stat_new();
res = csync_vio_stat(ctx, filename, fs);
}
if( res == 0) { if( res == 0) {
switch (fs->type) { switch (fs->type) {
@ -587,11 +605,7 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
previous_fs->child_modified = ctx->current_fs->child_modified; previous_fs->child_modified = ctx->current_fs->child_modified;
} }
if( ! do_read_from_db ) { csync_vio_file_stat_destroy(fs);
csync_vio_file_stat_destroy(fs);
} else {
SAFE_FREE(fs->etag);
}
if (rc < 0) { if (rc < 0) {
if (CSYNC_STATUS_IS_OK(ctx->status_code)) { if (CSYNC_STATUS_IS_OK(ctx->status_code)) {

View file

@ -26,7 +26,6 @@
#include <stdio.h> #include <stdio.h>
#include "csync_private.h" #include "csync_private.h"
#include "csync_dbtree.h"
#include "csync_util.h" #include "csync_util.h"
#include "vio/csync_vio.h" #include "vio/csync_vio.h"
#include "vio/csync_vio_handle_private.h" #include "vio/csync_vio_handle_private.h"
@ -364,11 +363,9 @@ csync_vio_handle_t *csync_vio_opendir(CSYNC *ctx, const char *name) {
switch(ctx->replica) { switch(ctx->replica) {
case REMOTE_REPLICA: case REMOTE_REPLICA:
if(ctx->remote.read_from_db) { if(ctx->remote.read_from_db) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Reading directory %s from database", name); CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "Read from db flag is true, should not!" );
mh = csync_dbtree_opendir(ctx, name);
} else {
mh = ctx->module.method->opendir(name);
} }
mh = ctx->module.method->opendir(name);
break; break;
case LOCAL_REPLICA: case LOCAL_REPLICA:
mh = csync_vio_local_opendir(name); mh = csync_vio_local_opendir(name);
@ -395,17 +392,16 @@ int csync_vio_closedir(CSYNC *ctx, csync_vio_handle_t *dhandle) {
} }
switch(ctx->replica) { switch(ctx->replica) {
case REMOTE_REPLICA: case REMOTE_REPLICA:
if(ctx->remote.read_from_db) { if( ctx->remote.read_from_db ) {
rc = csync_dbtree_closedir(ctx, dhandle->method_handle); CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "Remote ReadFromDb is true, should not!");
} else {
rc = ctx->module.method->closedir(dhandle->method_handle);
} }
rc = ctx->module.method->closedir(dhandle->method_handle);
break; break;
case LOCAL_REPLICA: case LOCAL_REPLICA:
rc = csync_vio_local_closedir(dhandle->method_handle); rc = csync_vio_local_closedir(dhandle->method_handle);
break; break;
default: default:
CSYNC_LOG(CSYNC_LOG_PRIORITY_ALERT, "Invalid replica (%d)", (int)ctx->replica); CSYNC_LOG(CSYNC_LOG_PRIORITY_ALERT, "Invalid replica (%d)", (int)ctx->replica);
break; break;
} }
@ -421,11 +417,10 @@ csync_vio_file_stat_t *csync_vio_readdir(CSYNC *ctx, csync_vio_handle_t *dhandle
switch(ctx->replica) { switch(ctx->replica) {
case REMOTE_REPLICA: case REMOTE_REPLICA:
if(ctx->remote.read_from_db) { if( ctx->remote.read_from_db ) {
fs = csync_dbtree_readdir(ctx, dhandle->method_handle); CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "Remote readfromdb is true, should not!");
} else {
fs = ctx->module.method->readdir(dhandle->method_handle);
} }
fs = ctx->module.method->readdir(dhandle->method_handle);
break; break;
case LOCAL_REPLICA: case LOCAL_REPLICA:
fs = csync_vio_local_readdir(dhandle->method_handle); fs = csync_vio_local_readdir(dhandle->method_handle);