Don't add deleted files to the journal.

This commit is contained in:
Andreas Schneider 2008-06-18 09:56:08 +02:00
parent 4246190524
commit 7935d63098
3 changed files with 27 additions and 23 deletions

View File

@ -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;
}

View File

@ -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 {

View File

@ -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);
}