]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dbox: Make sure we don't append to files that are already unlinked.
authorTimo Sirainen <tss@iki.fi>
Tue, 10 Mar 2009 02:10:52 +0000 (22:10 -0400)
committerTimo Sirainen <tss@iki.fi>
Tue, 10 Mar 2009 02:10:52 +0000 (22:10 -0400)
--HG--
branch : HEAD

src/lib-storage/index/dbox/dbox-map.c

index bfd9c1de4a42a7cd80ab9606a7eab88e49080750..7fee4552908744054001ab12fb0ada7234db69f6 100644 (file)
@@ -407,6 +407,7 @@ dbox_map_file_try_append(struct dbox_map_append_context *ctx,
        struct dbox_storage *storage = map->storage;
        const struct mail_index_header *hdr;
        struct dbox_file *file;
+       struct stat st;
        uint32_t seq, tmp_file_id;
        uoff_t tmp_offset, tmp_size, last_msg_offset, last_msg_size, new_size;
        bool deleted, file_too_old = FALSE;
@@ -432,6 +433,10 @@ dbox_map_file_try_append(struct dbox_map_append_context *ctx,
        else if ((ret = dbox_file_try_lock(file)) <= 0) {
                /* locking failed */
                *retry_later_r = ret == 0;
+       } else if (stat(file->current_path, &st) < 0) {
+               if (errno != ENOENT)
+                       i_error("stat(%s) failed: %m", file->current_path);
+               /* the file was unlinked between opening and locking it. */
        } else if (dbox_map_refresh(map) == 0) {
                /* now that the file is locked and map is refreshed, make sure
                   we still have the last msg's offset. we have to go through