Fix: If no database entry exists, the status is set to NEW.

This commit is contained in:
Klaas Freitag 2012-08-20 19:11:18 +03:00
parent 4a6b0e7241
commit ec63ab4e16

View file

@ -115,7 +115,8 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
} }
} }
#endif #endif
if (tmp && tmp->phash == h) { if(tmp) { /* there is an entry in the database */
if (tmp->phash == h) {
/* we have an update! */ /* we have an update! */
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "time compare: %lu <-> %lu, md5: %s <-> %s", CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "time compare: %lu <-> %lu, md5: %s <-> %s",
fs->mtime, tmp->modtime, fs->md5, tmp->md5); fs->mtime, tmp->modtime, fs->md5, tmp->md5);
@ -134,6 +135,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
if (type == CSYNC_FTW_TYPE_FILE && ctx->current == LOCAL_REPLICA) { if (type == CSYNC_FTW_TYPE_FILE && ctx->current == LOCAL_REPLICA) {
tmp = csync_statedb_get_stat_by_inode(ctx, fs->inode); tmp = csync_statedb_get_stat_by_inode(ctx, fs->inode);
if (tmp && tmp->inode == fs->inode) { if (tmp && tmp->inode == fs->inode) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "inodes: %ld <-> %ld", tmp->inode, fs->inode);
/* inode found so the file has been renamed */ /* inode found so the file has been renamed */
st->instruction = CSYNC_INSTRUCTION_RENAME; st->instruction = CSYNC_INSTRUCTION_RENAME;
goto out; goto out;
@ -149,6 +151,9 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
} else { } else {
st->instruction = CSYNC_INSTRUCTION_NEW; st->instruction = CSYNC_INSTRUCTION_NEW;
} }
} else {
st->instruction = CSYNC_INSTRUCTION_NEW;
}
out: out:
SAFE_FREE(tmp); SAFE_FREE(tmp);
@ -329,7 +334,7 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
int len = strlen( path ); int len = strlen( path );
uint64_t h = c_jhash64((uint8_t *) path, len, 0); uint64_t h = c_jhash64((uint8_t *) path, len, 0);
fs->md5 = csync_statedb_get_uniqId( ctx, h, fs ); fs->md5 = csync_statedb_get_uniqId( ctx, h, fs );
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Uniq ID read from Database: %s -> %s", path, fs->md5); CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Uniq ID read from Database: %s -> %s", path, fs->md5 ? fs->md5 : "<NULL>" );
} }
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "walk: %s", filename); CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "walk: %s", filename);