]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
maildir: When saving mails compressed, make sure ,S=size gets added to the filename.
authorTimo Sirainen <tss@iki.fi>
Wed, 25 Jan 2012 22:37:42 +0000 (00:37 +0200)
committerTimo Sirainen <tss@iki.fi>
Wed, 25 Jan 2012 22:37:42 +0000 (00:37 +0200)
src/lib-storage/index/maildir/maildir-save.c

index f19e6a2943802852de1a4cb893b83d2fe16d40e8..ba23ff61201e5227ce6562766a5c051978c9545f 100644 (file)
@@ -515,6 +515,7 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx)
        struct maildir_save_context *ctx = (struct maildir_save_context *)_ctx;
        struct mail_storage *storage = &ctx->mbox->storage->storage;
        const char *path;
+       off_t real_size;
        int output_errno;
 
        ctx->last_save_finished = TRUE;
@@ -570,6 +571,15 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx)
                        ctx->failed = TRUE;
                }
        }
+       real_size = lseek(ctx->fd, 0, SEEK_END);
+       if (real_size == (off_t)-1) {
+               mail_storage_set_critical(storage,
+                                         "lseek(%s) failed: %m", path);
+       } else if (real_size != (off_t)ctx->file_last->size) {
+               /* e.g. zlib plugin was used. the "physical size" must be in
+                  the maildir filename, since stat() will return wrong size */
+               ctx->file_last->preserve_filename = FALSE;
+       }
        if (close(ctx->fd) < 0) {
                if (!mail_storage_set_error_from_errno(storage)) {
                        mail_storage_set_critical(storage,