diff --git a/src/csync_journal.c b/src/csync_journal.c index 4a976fb27b..ae3562fb3c 100644 --- a/src/csync_journal.c +++ b/src/csync_journal.c @@ -268,25 +268,29 @@ static int visitor(void *obj, void *data) { fs = (csync_file_stat_t *) obj; ctx = (CSYNC *) data; - stmt = sqlite3_mprintf("INSERT INTO metadata_temp" - "(phash, pathlen, path, inode, uid, gid, mode, modtime) VALUES" - "(%lu, %d, '%q', %d, %d, %d, %d, %lu);", - fs->phash, - fs->pathlen, - fs->path, - fs->inode, - fs->uid, - fs->gid, - fs->mode, - fs->modtime); + if (fs->instruction != CSYNC_INSTRUCTION_DELETED) { + stmt = sqlite3_mprintf("INSERT INTO metadata_temp" + "(phash, pathlen, path, inode, uid, gid, mode, modtime) VALUES" + "(%lu, %d, '%q', %d, %d, %d, %d, %lu);", + fs->phash, + fs->pathlen, + fs->path, + fs->inode, + fs->uid, + fs->gid, + fs->mode, + fs->modtime); - if (stmt == NULL) { - return -1; + if (stmt == NULL) { + return -1; + } + + rc = csync_journal_insert(ctx, stmt); + sqlite3_free(stmt); + } else { + rc = 0; } - rc = csync_journal_insert(ctx, stmt); - sqlite3_free(stmt); - return rc; } diff --git a/src/csync_private.h b/src/csync_private.h index 2ef82ac73a..5dc307f417 100644 --- a/src/csync_private.h +++ b/src/csync_private.h @@ -133,7 +133,10 @@ enum csync_instructions_e { CSYNC_INSTRUCTION_IGNORE, CSYNC_INSTRUCTION_SYNC, CSYNC_INSTRUCTION_STAT_ERROR, - CSYNC_INSTRUCTION_ERROR + CSYNC_INSTRUCTION_ERROR, + /* instructions for the propagator */ + CSYNC_INSTRUCTION_DELETED, + CSYNC_INSTRUCTION_UPDATED }; typedef struct csync_file_stat_s { diff --git a/src/csync_propagate.c b/src/csync_propagate.c index 2b97962951..418716354e 100644 --- a/src/csync_propagate.c +++ b/src/csync_propagate.c @@ -313,8 +313,7 @@ static int _csync_remove_file(CSYNC *ctx, csync_file_stat_t *st) { goto out; } - /* FIXME: We can remove the node from the tree */ - st->instruction = CSYNC_INSTRUCTION_NONE; + st->instruction = CSYNC_INSTRUCTION_DELETED; CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "file: %s, instruction: REMOVED", uri); @@ -506,8 +505,7 @@ static int _csync_remove_dir(CSYNC *ctx, csync_file_stat_t *st) { goto out; } - /* FIXME: we can remove the node form the rbtree */ - st->instruction = CSYNC_INSTRUCTION_NONE; + st->instruction = CSYNC_INSTRUCTION_DELETED; CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "dir: %s, instruction: REMOVED", uri); @@ -558,8 +556,7 @@ static int _csync_propagation_cleanup(CSYNC *ctx) { CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "dir: %s, instruction: CLEANUP", dir); - /* FIXME: we can remove the node form the rbtree */ - st->instruction = CSYNC_INSTRUCTION_NONE; + st->instruction = CSYNC_INSTRUCTION_DELETED; SAFE_FREE(dir); }