]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dbox: Fixes.
authorTimo Sirainen <tss@iki.fi>
Wed, 11 Mar 2009 20:06:30 +0000 (16:06 -0400)
committerTimo Sirainen <tss@iki.fi>
Wed, 11 Mar 2009 20:06:30 +0000 (16:06 -0400)
--HG--
branch : HEAD

src/lib-storage/index/dbox/dbox-map.c
src/lib-storage/index/dbox/dbox-map.h
src/lib-storage/index/dbox/dbox-sync-file.c

index c7e443ca6ab3b2d8933521a2ed2023bcbf4ec726..b54ad8ddbcea2acbeeaa721d33ded683ab3cd66f 100644 (file)
@@ -800,13 +800,14 @@ int dbox_map_append_assign_map_uids(struct dbox_map_append_context *ctx,
 }
 
 int dbox_map_append_move(struct dbox_map_append_context *ctx,
-                        ARRAY_TYPE(seq_range) *map_uids,
-                        ARRAY_TYPE(seq_range) *expunge_map_uids)
+                        const ARRAY_TYPE(uint32_t) *map_uids,
+                        const ARRAY_TYPE(seq_range) *expunge_map_uids)
 {
        const struct dbox_map_append *appends;
        struct dbox_mail_index_map_record rec;
        struct seq_range_iter iter;
-       unsigned int i, j, appends_count;
+       const uint32_t *uids;
+       unsigned int i, j, map_uids_count, appends_count;
        uint32_t uid, seq;
 
        if (dbox_map_assign_file_ids(ctx) < 0)
@@ -815,15 +816,15 @@ int dbox_map_append_move(struct dbox_map_append_context *ctx,
        memset(&rec, 0, sizeof(rec));
        appends = array_get(&ctx->appends, &appends_count);
 
-       seq_range_array_iter_init(&iter, map_uids); i = j = 0;
-       while (seq_range_array_iter_nth(&iter, i++, &uid)) {
+       uids = array_get(map_uids, &map_uids_count);
+       for (i = j = 0; i < map_uids_count; i++) {
                i_assert(j < appends_count);
                rec.file_id = appends[j].file->file_id;
                rec.offset = appends[j].offset;
                rec.size = appends[j].size;
                j++;
 
-               if (!mail_index_lookup_seq(ctx->sync_view, uid, &seq))
+               if (!mail_index_lookup_seq(ctx->sync_view, uids[i], &seq))
                        i_unreached();
                mail_index_update_ext(ctx->trans, seq, ctx->map->map_ext_id,
                                      &rec, NULL);
index 538ab4bbe02bc55d46f058a3439676e0ff6d49c3..f28c1cd68702dd2e80e690132becd7d5bb91af90 100644 (file)
@@ -52,8 +52,8 @@ int dbox_map_append_assign_uids(struct dbox_map_append_context *ctx,
 /* The appends are existing messages that were simply moved to a new file.
    map_uids contains the moved messages' map UIDs. */
 int dbox_map_append_move(struct dbox_map_append_context *ctx,
-                        ARRAY_TYPE(seq_range) *map_uids,
-                        ARRAY_TYPE(seq_range) *expunge_map_uids);
+                        const ARRAY_TYPE(uint32_t) *map_uids,
+                        const ARRAY_TYPE(seq_range) *expunge_map_uids);
 /* Returns 0 if ok, -1 if error. */
 void dbox_map_append_commit(struct dbox_map_append_context **ctx);
 void dbox_map_append_rollback(struct dbox_map_append_context **ctx);
index fb8ca4f2e7a884e024fb3e0867b0f294a9ae6986..a5af64a9e1eadf26200d34eaf361bb68ad028bbb 100644 (file)
@@ -114,7 +114,8 @@ int dbox_sync_file_cleanup(struct dbox_file *file)
        struct dbox_map_append_context *append_ctx;
        ARRAY_TYPE(dbox_map_file_msg) msgs_arr;
        struct dbox_map_file_msg *msgs;
-       ARRAY_TYPE(seq_range) copied_map_uids, expunged_map_uids;
+       ARRAY_TYPE(seq_range) expunged_map_uids;
+       ARRAY_TYPE(uint32_t) copied_map_uids;
        unsigned int i, count;
        uoff_t offset, physical_size, msg_size;
        bool expunged;
@@ -197,8 +198,10 @@ int dbox_sync_file_cleanup(struct dbox_file *file)
                if ((ret = dbox_sync_file_copy_metadata(file, output)) <= 0)
                        break;
 
-               dbox_map_append_finish_multi_mail(append_ctx);
-               seq_range_array_add(&copied_map_uids, 0, msgs[i].map_uid);
+               if (output != NULL) {
+                       dbox_map_append_finish_multi_mail(append_ctx);
+                       array_append(&copied_map_uids, &msgs[i].map_uid, 1);
+               }
                offset = file->input->v_offset;
        }
        if (offset != (uoff_t)st.st_size && ret > 0) {
@@ -207,7 +210,6 @@ int dbox_sync_file_cleanup(struct dbox_file *file)
                        "more messages available than in map "
                        "(%"PRIuUOFF_T" < %"PRIuUOFF_T")", offset, st.st_size);
                ret = 0;
-               sleep(3600);
        }
        array_free(&msgs_arr); msgs = NULL;
 
@@ -220,7 +222,7 @@ int dbox_sync_file_cleanup(struct dbox_file *file)
                i_error("dbox error");
                dbox_map_append_rollback(&append_ctx);
                ret = -1;
-       } else if (output == NULL) {
+       } else if (array_count(&copied_map_uids) == 0) {
                /* everything expunged in this file, unlink it */
                ret = dbox_sync_file_unlink(file);
                dbox_map_append_rollback(&append_ctx);
@@ -288,7 +290,7 @@ int dbox_sync_file(struct dbox_sync_context *ctx,
                /* no expunges - we want to move it */
                dbox_sync_file_move_if_needed(file, entry);
        } else if (entry->uid != 0) {
-               /* fast path to expunging the whole file */
+               /* single-message file, we can unlink it */
                if ((ret = dbox_sync_file_unlink(file)) == 0) {
                        /* file was lost, delete it */
                        dbox_sync_mark_expunges(ctx, &entry->expunge_seqs);