From: Timo Sirainen Date: Tue, 10 Mar 2009 01:10:44 +0000 (-0400) Subject: dbox fixes X-Git-Tag: 2.0.alpha1~1038^2~58 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a61eb9fb0d67ac52592c19b129ebd43164c489c3;p=thirdparty%2Fdovecot%2Fcore.git dbox fixes --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/dbox/dbox-map.c b/src/lib-storage/index/dbox/dbox-map.c index cb812401cc..bfd9c1de4a 100644 --- a/src/lib-storage/index/dbox/dbox-map.c +++ b/src/lib-storage/index/dbox/dbox-map.c @@ -574,7 +574,8 @@ dbox_map_find_appendable_file(struct dbox_map_append_context *ctx, if (*file_r != NULL) return 1; /* FIXME: use retry_later somehow */ - if (!mail_index_lookup_seq_range(map->view, 1, uid-1, + if (uid == 1 || + !mail_index_lookup_seq_range(map->view, 1, uid-1, &seq1, &seq)) break; seq++; diff --git a/src/lib-storage/index/dbox/dbox-sync-file.c b/src/lib-storage/index/dbox/dbox-sync-file.c index fd1248beea..c7166c4ea2 100644 --- a/src/lib-storage/index/dbox/dbox-sync-file.c +++ b/src/lib-storage/index/dbox/dbox-sync-file.c @@ -45,6 +45,7 @@ static int dbox_sync_file_unlink(struct dbox_file *file) int dbox_sync_file_cleanup(struct dbox_file *file) { struct dbox_file *out_file; + struct stat st; struct istream *input; struct ostream *output = NULL; struct dbox_metadata_header meta_hdr; @@ -63,6 +64,18 @@ int dbox_sync_file_cleanup(struct dbox_file *file) if ((ret = dbox_file_try_lock(file)) <= 0) return ret; + /* make sure the file still exists. another process may have already + deleted it. */ + if (stat(file->current_path, &st) < 0) { + dbox_file_unlock(file); + if (errno == ENOENT) + return 0; + + mail_storage_set_critical(&file->storage->storage, + "stat(%s) failed: %m", file->current_path); + return -1; + } + append_ctx = dbox_map_append_begin_storage(file->storage); i_array_init(&msgs_arr, 128); @@ -153,8 +166,8 @@ int dbox_sync_file_cleanup(struct dbox_file *file) ret = -1; } else if (output == NULL) { /* everything expunged in this file, unlink it */ - dbox_map_append_rollback(&append_ctx); ret = dbox_sync_file_unlink(file); + dbox_map_append_rollback(&append_ctx); } else { /* assign new file_id + offset to moved messages */ if (dbox_map_append_move(append_ctx, &copied_map_uids, @@ -163,8 +176,8 @@ int dbox_sync_file_cleanup(struct dbox_file *file) dbox_map_append_rollback(&append_ctx); ret = -1; } else { - dbox_map_append_commit(&append_ctx); (void)dbox_sync_file_unlink(file); + dbox_map_append_commit(&append_ctx); ret = 1; } }