This commit is contained in:
Klaas Freitag 2014-03-20 12:34:54 +01:00
Родитель ba2ff4ec46
Коммит a5ede054d6
3 изменённых файлов: 13 добавлений и 14 удалений

Просмотреть файл

@ -307,17 +307,15 @@ int csync_statedb_close(CSYNC *ctx, int jwritten) {
/* close the temporary database */
sqlite3_close(ctx->statedb.db);
if (asprintf(&statedb_tmp, "%s.ctmp", ctx->statedb.file) < 0) {
return -1;
}
/* If we successfully synchronized, overwrite the original statedb */
/*
* Check the integrity of the tmp db. If ok, overwrite the old database with
* the tmp db.
/* If we successfully synchronized, overwrite the original statedb
*
* First check the integrity of the tmp db. If ok, overwrite the old
* database with the tmp db.
*/
if (jwritten) {
if (!ctx->statedb.file || asprintf(&statedb_tmp, "%s.ctmp", ctx->statedb.file) < 0) {
return -1;
}
/* statedb check returns either
* 0 : database exists and is fine
* 1 : new database was set up

Просмотреть файл

@ -43,6 +43,7 @@ static void setup(void **state) {
csync_set_config_dir(csync, "/tmp/check_csync1/");
csync->statedb.file = c_strdup( TESTDB );
*state = csync;
}
@ -123,7 +124,7 @@ static void check_csync_statedb_close(void **state)
assert_int_equal(rc, 0);
modtime = sb.st_mtime;
rc = csync_statedb_close(TESTDB, csync->statedb.db, 0);
rc = csync_statedb_close(csync, 0);
assert_int_equal(rc, 0);
rc = _tstat(testdb, &sb);
@ -140,7 +141,7 @@ static void check_csync_statedb_close(void **state)
sleep(1);
/* statedb written */
rc = csync_statedb_close(TESTDB, csync->statedb.db, 1);
rc = csync_statedb_close(csync, 1);
assert_int_equal(rc, 0);
rc = _tstat(testdb, &sb);

Просмотреть файл

@ -237,7 +237,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->statedb.db, (uint64_t) 666);
tmp = csync_statedb_get_stat_by_hash(csync, (uint64_t) 666);
assert_null(tmp);
free(tmp);
@ -248,7 +248,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->statedb.db, (ino_t) 23);
tmp = csync_statedb_get_stat_by_inode(csync, (ino_t) 23);
assert_non_null(tmp);
assert_int_equal(tmp->phash, 42);
@ -262,7 +262,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->statedb.db, (ino_t) 666);
tmp = csync_statedb_get_stat_by_inode(csync, (ino_t) 666);
assert_null(tmp);
}