[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-sync.c,
1.17, 1.18
cras at procontrol.fi
cras at procontrol.fi
Sun May 23 00:30:44 EEST 2004
- Previous message: [dovecot-cvs] dovecot/src/lib-storage/index index-sync.c,1.32,1.33
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-index-fsck.c, 1.19,
1.20 mail-index-sync-update.c, 1.15, 1.16 mail-index.c, 1.121,
1.122 mail-index.h, 1.109, 1.110
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv4692/lib-storage/index/maildir
Modified Files:
maildir-sync.c
Log Message:
Set dirty flags through transaction log, not directly. Some other flag
fixes etc.
Index: maildir-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-sync.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- a/maildir-sync.c 22 May 2004 01:18:17 -0000 1.17
+++ b/maildir-sync.c 22 May 2004 21:30:42 -0000 1.18
@@ -197,11 +197,13 @@
struct maildir_index_sync_context {
struct index_mailbox *ibox;
- struct mail_index_view *view;
+ struct mail_index_view *view;
struct mail_index_sync_ctx *sync_ctx;
+ struct mail_index_transaction *trans;
struct mail_index_sync_rec sync_rec;
uint32_t seq;
+ int have_dirty, last_dirty;
};
static int maildir_expunge(struct index_mailbox *ibox, const char *path,
@@ -228,6 +230,8 @@
uint8_t flags8;
keywords_mask_t keywords;
+ ctx->last_dirty = FALSE;
+
(void)maildir_filename_get_flags(path, &flags, keywords);
flags8 = flags;
@@ -241,9 +245,11 @@
if (errno == ENOENT)
return 0;
- if (ENOSPACE(errno)) {
- if (mail_index_sync_set_dirty(ctx->sync_ctx, ctx->seq) < 0)
- return -1;
+ if (ENOSPACE(errno) || errno == EACCES) {
+ memset(keywords, 0, sizeof(keywords));
+ mail_index_update_flags(ctx->trans, ctx->seq, MODIFY_ADD,
+ MAIL_INDEX_MAIL_FLAG_DIRTY, keywords);
+ ctx->last_dirty = TRUE;
return 1;
}
@@ -257,6 +263,7 @@
{
struct mail_index_sync_rec *sync_rec = &ctx->sync_rec;
struct mail_index_view *view = ctx->view;
+ const struct mail_index_record *rec;
uint32_t seq, seq1, seq2, uid;
switch (sync_rec->type) {
@@ -293,9 +300,23 @@
for (ctx->seq = seq1; ctx->seq <= seq2; ctx->seq++) {
if (mail_index_lookup_uid(view, ctx->seq, &uid) < 0)
return -1;
- if (maildir_file_do(ibox, uid, maildir_sync_flags,
- ctx) < 0)
+ if (maildir_file_do(ibox, uid,
+ maildir_sync_flags, ctx) < 0)
return -1;
+ if (!ctx->last_dirty) {
+ /* if this flag was dirty, drop it */
+ if (mail_index_lookup(view, ctx->seq, &rec) < 0)
+ return -1;
+ if (rec->flags & MAIL_INDEX_MAIL_FLAG_DIRTY) {
+ keywords_mask_t keywords;
+
+ memset(keywords, 0, sizeof(keywords));
+ mail_index_update_flags(ctx->trans,
+ ctx->seq, MODIFY_REMOVE,
+ MAIL_INDEX_MAIL_FLAG_DIRTY,
+ keywords);
+ }
+ }
}
break;
}
@@ -306,6 +327,9 @@
int maildir_sync_last_commit(struct index_mailbox *ibox)
{
struct maildir_index_sync_context ctx;
+ const struct mail_index_header *hdr;
+ uint32_t seq;
+ uoff_t offset;
int ret;
if (ibox->commit_log_file_seq == 0)
@@ -318,6 +342,12 @@
ibox->commit_log_file_seq,
ibox->commit_log_file_offset);
if (ret > 0) {
+ if (mail_index_get_header(ctx.view, &hdr) == 0 &&
+ (hdr->flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0)
+ ctx.have_dirty = TRUE;
+
+ ctx.trans = mail_index_transaction_begin(ctx.view, FALSE);
+
while ((ret = mail_index_sync_next(ctx.sync_ctx,
&ctx.sync_rec)) > 0) {
if (maildir_sync_record(ibox, &ctx) < 0) {
@@ -325,6 +355,8 @@
break;
}
}
+ if (mail_index_transaction_commit(ctx.trans, &seq, &offset) < 0)
+ ret = -1;
if (mail_index_sync_end(ctx.sync_ctx, 0, 0) < 0)
ret = -1;
}
@@ -557,6 +589,7 @@
i_assert(ret == 0); /* view is locked, can't happen */
trans = mail_index_transaction_begin(view, FALSE);
+ sync_ctx.trans = trans;
seq = 0;
iter = maildir_uidlist_iter_init(ibox->uidlist);
@@ -658,6 +691,15 @@
mail_index_expunge(trans, seq);
}
+ /* now, sync the index */
+ while ((ret = mail_index_sync_next(sync_ctx.sync_ctx,
+ &sync_ctx.sync_rec)) > 0) {
+ if (maildir_sync_record(ibox, &sync_ctx) < 0) {
+ ret = -1;
+ break;
+ }
+ }
+
if (ret < 0)
mail_index_transaction_rollback(trans);
else {
@@ -672,15 +714,6 @@
}
}
- /* now, sync the index */
- while ((ret = mail_index_sync_next(sync_ctx.sync_ctx,
- &sync_ctx.sync_rec)) > 0) {
- if (maildir_sync_record(ibox, &sync_ctx) < 0) {
- ret = -1;
- break;
- }
- }
-
sync_stamp = ibox->dirty_cur_time != 0 ? 0 : ibox->last_cur_mtime;
if (mail_index_sync_end(sync_ctx.sync_ctx, sync_stamp, 0) < 0)
ret = -1;
- Previous message: [dovecot-cvs] dovecot/src/lib-storage/index index-sync.c,1.32,1.33
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-index-fsck.c, 1.19,
1.20 mail-index-sync-update.c, 1.15, 1.16 mail-index.c, 1.121,
1.122 mail-index.h, 1.109, 1.110
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list