Always remove the temporary journal.

This commit is contained in:
Andreas Schneider 2008-05-20 16:14:14 +02:00
parent dddb81c5cd
commit 6601a2e49e

View file

@ -163,17 +163,20 @@ int csync_journal_close(CSYNC *ctx, const char *journal, int jwritten) {
/* close the temporary database */
sqlite3_close(ctx->journal.db);
if (asprintf(&journal_tmp, "%s.ctmp", journal) < 0) {
return -1;
}
/* if we successfully synchronized, overwrite the original journal */
if (jwritten) {
if (asprintf(&journal_tmp, "%s.ctmp", journal) < 0) {
return -1;
}
rc = c_copy(journal_tmp, journal, 0644);
if (rc == 0) {
unlink(journal_tmp);
}
SAFE_FREE(journal_tmp);
} else {
unlink(journal_tmp);
}
SAFE_FREE(journal_tmp);
return rc;
}