statedb: Remove context where it isn't needed.

This commit is contained in:
Andreas Schneider 2013-07-04 10:28:19 +02:00
parent d05b077851
commit 8953ed544c
7 changed files with 82 additions and 84 deletions

View file

@ -683,7 +683,7 @@ static int _merge_and_write_statedb(CSYNC *ctx) {
}
}
}
rc = csync_statedb_close(ctx, ctx->statedb.file, ctx->statedb.db, jwritten);
rc = csync_statedb_close(ctx->statedb.file, ctx->statedb.db, jwritten);
ctx->statedb.db = NULL;
if (rc < 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "ERR: closing of statedb failed.");

View file

@ -50,11 +50,11 @@ int csync_get_statedb_exists(CSYNC *ctx) {
return ctx->statedb.exists;
}
static int _csync_check_db_integrity(CSYNC *ctx, sqlite3 *db) {
static int _csync_check_db_integrity(sqlite3 *db) {
c_strlist_t *result = NULL;
int rc = -1;
result = csync_statedb_query(ctx, db, "PRAGMA quick_check;");
result = csync_statedb_query(db, "PRAGMA quick_check;");
if (result != NULL) {
/* There is a result */
if (result->count > 0) {
@ -69,7 +69,7 @@ static int _csync_check_db_integrity(CSYNC *ctx, sqlite3 *db) {
}
static int _csync_statedb_check(CSYNC *ctx, const char *statedb) {
static int _csync_statedb_check(const char *statedb) {
int fd = -1, rc;
ssize_t r;
char buf[BUF_SIZE] = {0};
@ -94,7 +94,7 @@ static int _csync_statedb_check(CSYNC *ctx, const char *statedb) {
buf[BUF_SIZE - 1] = '\0';
if (c_streq(buf, "SQLite format 3")) {
if (sqlite3_open(statedb, &db ) == SQLITE_OK) {
rc = _csync_check_db_integrity(ctx, db);
rc = _csync_check_db_integrity(db);
sqlite3_close(db);
@ -129,11 +129,11 @@ static int _csync_statedb_check(CSYNC *ctx, const char *statedb) {
return -1;
}
static int _csync_statedb_is_empty(CSYNC *ctx, sqlite3 *db) {
static int _csync_statedb_is_empty(sqlite3 *db) {
c_strlist_t *result = NULL;
int rc = 0;
result = csync_statedb_query(ctx, db, "SELECT COUNT(phash) FROM metadata LIMIT 1 OFFSET 0;");
result = csync_statedb_query(db, "SELECT COUNT(phash) FROM metadata LIMIT 1 OFFSET 0;");
if (result == NULL) {
rc = 1;
}
@ -148,7 +148,7 @@ int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb) {
char *statedb_tmp = NULL;
sqlite3 *db;
if (_csync_statedb_check(ctx, statedb) < 0) {
if (_csync_statedb_check(statedb) < 0) {
rc = -1;
goto out;
}
@ -176,7 +176,7 @@ int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb) {
}
SAFE_FREE(statedb_tmp);
if (_csync_statedb_is_empty(ctx, db)) {
if (_csync_statedb_is_empty(db)) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_NOTICE, "statedb doesn't exist");
csync_set_statedb_exists(ctx, 0);
} else {
@ -184,7 +184,7 @@ int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb) {
}
/* optimization for speeding up SQLite */
result = csync_statedb_query(ctx, db, "PRAGMA default_synchronous = FULL;");
result = csync_statedb_query(db, "PRAGMA default_synchronous = FULL;");
c_strlist_destroy(result);
*pdb = db;
@ -203,7 +203,7 @@ int csync_statedb_write(CSYNC *ctx, sqlite3 *db)
csync_gettime(&start);
/* drop tables */
rc = csync_statedb_drop_tables(ctx, db);
rc = csync_statedb_drop_tables(db);
if (rc < 0) {
return -1;
}
@ -214,7 +214,7 @@ int csync_statedb_write(CSYNC *ctx, sqlite3 *db)
/* create tables */
csync_gettime(&start);
rc = csync_statedb_create_tables(ctx, db);
rc = csync_statedb_create_tables(db);
if (rc < 0) {
return -1;
}
@ -237,7 +237,7 @@ int csync_statedb_write(CSYNC *ctx, sqlite3 *db)
return 0;
}
int csync_statedb_close(CSYNC *ctx, const char *statedb, sqlite3 *db, int jwritten) {
int csync_statedb_close(const char *statedb, sqlite3 *db, int jwritten) {
char *statedb_tmp = NULL;
int rc = 0;
@ -262,7 +262,7 @@ int csync_statedb_close(CSYNC *ctx, const char *statedb, sqlite3 *db, int jwritt
return rc;
}
int csync_statedb_create_tables(CSYNC *ctx, sqlite3 *db) {
int csync_statedb_create_tables(sqlite3 *db) {
c_strlist_t *result = NULL;
/*
@ -270,7 +270,7 @@ int csync_statedb_create_tables(CSYNC *ctx, sqlite3 *db) {
* creation of the statedb if we later just rename it to its
* final name metadata
*/
result = csync_statedb_query(ctx, db,
result = csync_statedb_query(db,
"CREATE TABLE IF NOT EXISTS metadata_temp("
"phash INTEGER(8),"
"pathlen INTEGER,"
@ -294,7 +294,7 @@ int csync_statedb_create_tables(CSYNC *ctx, sqlite3 *db) {
* for first time sync. Otherwise other functions that query metadata
* table whine about the table not existing.
*/
result = csync_statedb_query(ctx, db,
result = csync_statedb_query(db,
"CREATE TABLE IF NOT EXISTS metadata("
"phash INTEGER(8),"
"pathlen INTEGER,"
@ -317,10 +317,10 @@ int csync_statedb_create_tables(CSYNC *ctx, sqlite3 *db) {
return 0;
}
int csync_statedb_drop_tables(CSYNC *ctx, sqlite3* db) {
int csync_statedb_drop_tables(sqlite3* db) {
c_strlist_t *result = NULL;
result = csync_statedb_query(ctx, db,
result = csync_statedb_query(db,
"DROP TABLE IF EXISTS metadata_temp;"
);
if (result == NULL) {
@ -418,21 +418,21 @@ int csync_statedb_insert_metadata(CSYNC *ctx, sqlite3 *db) {
}
/* Use transactions as that really speeds up processing */
result = csync_statedb_query(ctx, db, "BEGIN TRANSACTION;");
result = csync_statedb_query(db, "BEGIN TRANSACTION;");
c_strlist_destroy(result);
if (c_rbtree_walk(ctx->local.tree, stmt, _insert_metadata_visitor) < 0) {
/* inserting failed. Drop the metadata_temp table. */
result = csync_statedb_query(ctx, db, "ROLLBACK TRANSACTION;");
result = csync_statedb_query(db, "ROLLBACK TRANSACTION;");
c_strlist_destroy(result);
result = csync_statedb_query(ctx, db, "DROP TABLE IF EXISTS metadata_temp;");
result = csync_statedb_query(db, "DROP TABLE IF EXISTS metadata_temp;");
c_strlist_destroy(result);
return -1;
}
result = csync_statedb_query(ctx, db, "COMMIT TRANSACTION;");
result = csync_statedb_query(db, "COMMIT TRANSACTION;");
c_strlist_destroy(result);
sqlite3_finalize(stmt);
@ -442,17 +442,17 @@ int csync_statedb_insert_metadata(CSYNC *ctx, sqlite3 *db) {
c_secdiff(step1, start));
/* Drop table metadata */
result = csync_statedb_query(ctx, db, "BEGIN TRANSACTION;");
result = csync_statedb_query(db, "BEGIN TRANSACTION;");
c_strlist_destroy(result);
result = csync_statedb_query(ctx, db, "DROP TABLE IF EXISTS metadata;");
result = csync_statedb_query(db, "DROP TABLE IF EXISTS metadata;");
c_strlist_destroy(result);
/* Rename temp table to real table. */
result = csync_statedb_query(ctx, db, "ALTER TABLE metadata_temp RENAME TO metadata;");
result = csync_statedb_query(db, "ALTER TABLE metadata_temp RENAME TO metadata;");
c_strlist_destroy(result);
result = csync_statedb_query(ctx, db, "COMMIT TRANSACTION;");
result = csync_statedb_query(db, "COMMIT TRANSACTION;");
c_strlist_destroy(result);
csync_gettime(&step2);
@ -461,24 +461,24 @@ int csync_statedb_insert_metadata(CSYNC *ctx, sqlite3 *db) {
c_secdiff(step2, step1));
/* Recreate indices */
result = csync_statedb_query(ctx, db, "BEGIN TRANSACTION;");
result = csync_statedb_query(db, "BEGIN TRANSACTION;");
c_strlist_destroy(result);
result = csync_statedb_query(ctx, db,
result = csync_statedb_query(db,
"CREATE INDEX IF NOT EXISTS metadata_phash ON metadata(phash);");
if (result == NULL) {
return -1;
}
c_strlist_destroy(result);
result = csync_statedb_query(ctx, db,
result = csync_statedb_query(db,
"CREATE INDEX IF NOT EXISTS metadata_inode ON metadata(inode);");
if (result == NULL) {
return -1;
}
c_strlist_destroy(result);
result = csync_statedb_query(ctx, db, "COMMIT TRANSACTION;");
result = csync_statedb_query(db, "COMMIT TRANSACTION;");
c_strlist_destroy(result);
csync_gettime(&finish);
@ -491,8 +491,7 @@ int csync_statedb_insert_metadata(CSYNC *ctx, sqlite3 *db) {
}
/* caller must free the memory */
csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx,
sqlite3 *db,
csync_file_stat_t *csync_statedb_get_stat_by_hash(sqlite3 *db,
uint64_t phash)
{
csync_file_stat_t *st = NULL;
@ -508,7 +507,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx,
return NULL;
}
result = csync_statedb_query(ctx, db, stmt);
result = csync_statedb_query(db, stmt);
sqlite3_free(stmt);
if (result == NULL) {
return NULL;
@ -553,8 +552,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx,
}
/* caller must free the memory */
csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx,
sqlite3 *db,
csync_file_stat_t *csync_statedb_get_stat_by_inode(sqlite3 *db,
ino_t inode) {
csync_file_stat_t *st = NULL;
c_strlist_t *result = NULL;
@ -572,7 +570,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx,
return NULL;
}
result = csync_statedb_query(ctx, db, stmt);
result = csync_statedb_query(db, stmt);
sqlite3_free(stmt);
if (result == NULL) {
return NULL;
@ -606,8 +604,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx,
}
/* query the statedb, caller must free the memory */
c_strlist_t *csync_statedb_query(CSYNC *ctx,
sqlite3 *db,
c_strlist_t *csync_statedb_query(sqlite3 *db,
const char *statement) {
int err = SQLITE_OK;
int rc = SQLITE_OK;
@ -721,7 +718,7 @@ c_strlist_t *csync_statedb_query(CSYNC *ctx,
return result;
}
int csync_statedb_insert(CSYNC *ctx, sqlite3 *db, const char *statement) {
int csync_statedb_insert(sqlite3 *db, const char *statement) {
int err;
int rc = 0;
int busy_count = 0;

View file

@ -55,11 +55,11 @@ int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb);
int csync_statedb_write(CSYNC *ctx, sqlite3 *db);
int csync_statedb_close(CSYNC *ctx, const char *statedb, sqlite3 *db, int jwritten);
int csync_statedb_close(const char *statedb, sqlite3 *db, int jwritten);
csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx, sqlite3 *db, uint64_t phash);
csync_file_stat_t *csync_statedb_get_stat_by_hash(sqlite3 *db, uint64_t phash);
csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx, sqlite3 *db, ino_t inode);
csync_file_stat_t *csync_statedb_get_stat_by_inode(sqlite3 *db, ino_t inode);
/**
* @brief A generic statedb query.
@ -70,7 +70,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx, sqlite3 *db, ino_
* @return A stringlist of the entries of a column. An emtpy stringlist if
* nothing has been found. NULL on error.
*/
c_strlist_t *csync_statedb_query(CSYNC *ctx, sqlite3 *db, const char *statement);
c_strlist_t *csync_statedb_query(sqlite3 *db, const char *statement);
/**
* @brief Insert function for the statedb.
@ -81,11 +81,11 @@ c_strlist_t *csync_statedb_query(CSYNC *ctx, sqlite3 *db, const char *statement)
* @return The rowid of the most recent INSERT on success, 0 if the query
* wasn't successful.
*/
int csync_statedb_insert(CSYNC *ctx, sqlite3 *db, const char *statement);
int csync_statedb_insert(sqlite3 *db, const char *statement);
int csync_statedb_create_tables(CSYNC *ctx, sqlite3 *db);
int csync_statedb_create_tables(sqlite3 *db);
int csync_statedb_drop_tables(CSYNC *ctx, sqlite3 *db);
int csync_statedb_drop_tables(sqlite3 *db);
int csync_statedb_insert_metadata(CSYNC *ctx, sqlite3 *db);

View file

@ -104,7 +104,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
/* Update detection */
if (csync_get_statedb_exists(ctx)) {
tmp = csync_statedb_get_stat_by_hash(ctx, ctx->statedb.db, h);
tmp = csync_statedb_get_stat_by_hash(ctx->statedb.db, h);
if (tmp && tmp->phash == h) {
/* we have an update! */
if (fs->mtime > tmp->modtime) {
@ -116,7 +116,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
/* check if the file has been renamed */
if (ctx->current == LOCAL_REPLICA) {
SAFE_FREE(tmp);
tmp = csync_statedb_get_stat_by_inode(ctx, ctx->statedb.db, fs->inode);
tmp = csync_statedb_get_stat_by_inode(ctx->statedb.db, fs->inode);
if (tmp && tmp->inode == fs->inode) {
/* inode found so the file has been renamed */
st->instruction = CSYNC_INSTRUCTION_RENAME;

View file

@ -44,27 +44,28 @@ static void teardown(void **state) {
static void check_csync_statedb_check(void **state)
{
int rc;
CSYNC *csync = *state;
(void) state; /* unused */
rc = system("mkdir -p /tmp/check_csync1");
/* old db */
rc = system("echo \"SQLite format 2\" > /tmp/check_csync1/test.db");
assert_int_equal(rc, 0);
rc = _csync_statedb_check(csync, TESTDB);
rc = _csync_statedb_check(TESTDB);
assert_int_equal(rc, 0);
/* db already exists */
rc = _csync_statedb_check(csync, TESTDB);
rc = _csync_statedb_check(TESTDB);
assert_int_equal(rc, 0);
/* no db exists */
rc = system("rm -f /tmp/check_csync1/test.db");
assert_int_equal(rc, 0);
rc = _csync_statedb_check(csync, TESTDB);
rc = _csync_statedb_check(TESTDB);
assert_int_equal(rc, 0);
rc = _csync_statedb_check(csync, "/tmp/check_csync1/");
rc = _csync_statedb_check("/tmp/check_csync1/");
assert_int_equal(rc, -1);
rc = system("rm -rf /tmp/check_csync1");
@ -104,7 +105,7 @@ static void check_csync_statedb_close(void **state)
assert_int_equal(rc, 0);
modtime = sb.st_mtime;
rc = csync_statedb_close(csync, TESTDB, csync->statedb.db, 0);
rc = csync_statedb_close(TESTDB, csync->statedb.db, 0);
assert_int_equal(rc, 0);
rc = _tstat(testdb, &sb);
@ -121,7 +122,7 @@ static void check_csync_statedb_close(void **state)
sleep(1);
/* statedb written */
rc = csync_statedb_close(csync, TESTDB, csync->statedb.db, 1);
rc = csync_statedb_close(TESTDB, csync->statedb.db, 1);
assert_int_equal(rc, 0);
rc = _tstat(testdb, &sb);

View file

@ -40,7 +40,7 @@ static void setup_db(void **state)
setup(state);
csync = *state;
rc = csync_statedb_create_tables(csync, csync->statedb.db);
rc = csync_statedb_create_tables(csync->statedb.db);
assert_int_equal(rc, 0);
stmt = sqlite3_mprintf("INSERT INTO metadata"
@ -55,7 +55,7 @@ static void setup_db(void **state)
42,
42);
rc = csync_statedb_insert(csync, csync->statedb.db, stmt);
rc = csync_statedb_insert(csync->statedb.db, stmt);
sqlite3_free(stmt);
}
@ -81,10 +81,10 @@ static void check_csync_statedb_query_statement(void **state)
CSYNC *csync = *state;
c_strlist_t *result;
result = csync_statedb_query(csync, csync->statedb.db, "");
result = csync_statedb_query(csync->statedb.db, "");
assert_null(result);
result = csync_statedb_query(csync, csync->statedb.db, "SELECT;");
result = csync_statedb_query(csync->statedb.db, "SELECT;");
assert_null(result);
}
@ -93,11 +93,11 @@ static void check_csync_statedb_create_error(void **state)
CSYNC *csync = *state;
c_strlist_t *result;
result = csync_statedb_query(csync, csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
result = csync_statedb_query(csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
assert_non_null(result);
c_strlist_destroy(result);
result = csync_statedb_query(csync, csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
result = csync_statedb_query(csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
assert_null(result);
}
@ -107,15 +107,15 @@ static void check_csync_statedb_insert_statement(void **state)
c_strlist_t *result;
int rc;
result = csync_statedb_query(csync, csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
result = csync_statedb_query(csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
assert_non_null(result);
c_strlist_destroy(result);
rc = csync_statedb_insert(csync, csync->statedb.db, "INSERT;");
rc = csync_statedb_insert(csync->statedb.db, "INSERT;");
assert_int_equal(rc, 0);
rc = csync_statedb_insert(csync, csync->statedb.db, "INSERT");
rc = csync_statedb_insert(csync->statedb.db, "INSERT");
assert_int_equal(rc, 0);
rc = csync_statedb_insert(csync, csync->statedb.db, "");
rc = csync_statedb_insert(csync->statedb.db, "");
assert_int_equal(rc, 0);
}
@ -125,12 +125,12 @@ static void check_csync_statedb_query_create_and_insert_table(void **state)
c_strlist_t *result;
int rc;
result = csync_statedb_query(csync, csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
result = csync_statedb_query(csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
c_strlist_destroy(result);
rc = csync_statedb_insert(csync, csync->statedb.db, "INSERT INTO test (phash, text) VALUES (42, 'hello');");
rc = csync_statedb_insert(csync->statedb.db, "INSERT INTO test (phash, text) VALUES (42, 'hello');");
assert_true(rc > 0);
result = csync_statedb_query(csync, csync->statedb.db, "SELECT * FROM test;");
result = csync_statedb_query(csync->statedb.db, "SELECT * FROM test;");
assert_non_null(result);
assert_int_equal(result->count, 2);
@ -146,15 +146,15 @@ static void check_csync_statedb_is_empty(void **state)
int rc;
/* we have an empty db */
assert_true(_csync_statedb_is_empty(csync, csync->statedb.db));
assert_true(_csync_statedb_is_empty(csync->statedb.db));
/* add a table and an entry */
result = csync_statedb_query(csync, csync->statedb.db, "CREATE TABLE metadata(phash INTEGER, text VARCHAR(10));");
result = csync_statedb_query(csync->statedb.db, "CREATE TABLE metadata(phash INTEGER, text VARCHAR(10));");
c_strlist_destroy(result);
rc = csync_statedb_insert(csync, csync->statedb.db, "INSERT INTO metadata (phash, text) VALUES (42, 'hello');");
rc = csync_statedb_insert(csync->statedb.db, "INSERT INTO metadata (phash, text) VALUES (42, 'hello');");
assert_true(rc > 0);
assert_false(_csync_statedb_is_empty(csync, csync->statedb.db));
assert_false(_csync_statedb_is_empty(csync->statedb.db));
}
static void check_csync_statedb_create_tables(void **state)
@ -163,7 +163,7 @@ static void check_csync_statedb_create_tables(void **state)
char *stmt = NULL;
int rc;
rc = csync_statedb_create_tables(csync, csync->statedb.db);
rc = csync_statedb_create_tables(csync->statedb.db);
assert_int_equal(rc, 0);
stmt = sqlite3_mprintf("INSERT INTO metadata"
@ -178,7 +178,7 @@ static void check_csync_statedb_create_tables(void **state)
42,
42);
rc = csync_statedb_insert(csync, csync->statedb.db, stmt);
rc = csync_statedb_insert(csync->statedb.db, stmt);
assert_true(rc > 0);
sqlite3_free(stmt);
@ -189,11 +189,11 @@ static void check_csync_statedb_drop_tables(void **state)
CSYNC *csync = *state;
int rc;
rc = csync_statedb_drop_tables(csync, csync->statedb.db);
rc = csync_statedb_drop_tables(csync->statedb.db);
assert_int_equal(rc, 0);
rc = csync_statedb_create_tables(csync, csync->statedb.db);
rc = csync_statedb_create_tables(csync->statedb.db);
assert_int_equal(rc, 0);
rc = csync_statedb_drop_tables(csync, csync->statedb.db);
rc = csync_statedb_drop_tables(csync->statedb.db);
assert_int_equal(rc, 0);
}
@ -203,7 +203,7 @@ static void check_csync_statedb_insert_metadata(void **state)
csync_file_stat_t *st;
int i, rc;
rc = csync_statedb_create_tables(csync, csync->statedb.db);
rc = csync_statedb_create_tables(csync->statedb.db);
assert_int_equal(rc, 0);
for (i = 0; i < 100; i++) {
@ -241,7 +241,7 @@ static void check_csync_statedb_get_stat_by_hash(void **state)
CSYNC *csync = *state;
csync_file_stat_t *tmp;
tmp = csync_statedb_get_stat_by_hash(csync, csync->statedb.db, (uint64_t) 42);
tmp = csync_statedb_get_stat_by_hash(csync->statedb.db, (uint64_t) 42);
assert_non_null(tmp);
assert_int_equal(tmp->phash, 42);
@ -255,7 +255,7 @@ static void check_csync_statedb_get_stat_by_hash_not_found(void **state)
CSYNC *csync = *state;
csync_file_stat_t *tmp;
tmp = csync_statedb_get_stat_by_hash(csync, csync->statedb.db, (uint64_t) 666);
tmp = csync_statedb_get_stat_by_hash(csync->statedb.db, (uint64_t) 666);
assert_null(tmp);
}
@ -264,7 +264,7 @@ static void check_csync_statedb_get_stat_by_inode(void **state)
CSYNC *csync = *state;
csync_file_stat_t *tmp;
tmp = csync_statedb_get_stat_by_inode(csync, csync->statedb.db, (ino_t) 23);
tmp = csync_statedb_get_stat_by_inode(csync->statedb.db, (ino_t) 23);
assert_non_null(tmp);
assert_int_equal(tmp->phash, 42);
@ -278,7 +278,7 @@ static void check_csync_statedb_get_stat_by_inode_not_found(void **state)
CSYNC *csync = *state;
csync_file_stat_t *tmp;
tmp = csync_statedb_get_stat_by_inode(csync, csync->statedb.db, (ino_t) 666);
tmp = csync_statedb_get_stat_by_inode(csync->statedb.db, (ino_t) 666);
assert_null(tmp);
}

View file

@ -247,7 +247,7 @@ static void check_csync_detect_update_db_rename(void **state)
int rc;
char *stmt = NULL;
rc = csync_statedb_create_tables(csync, csync->statedb.db);
rc = csync_statedb_create_tables(csync->statedb.db);
assert_int_equal(rc, 0);
stmt = sqlite3_mprintf("INSERT INTO metadata"
@ -262,7 +262,7 @@ static void check_csync_detect_update_db_rename(void **state)
42,
42);
rc = csync_statedb_insert(csync, csync->statedb.db, stmt);
rc = csync_statedb_insert(csync->statedb.db, stmt);
sqlite3_free(stmt);
fs = create_fstat("wurst.txt", 0, 1, 0);