~ubuntu-dev/ubuntu/lucid/dovecot/lucid-201002101901

« back to all changes in this revision

Viewing changes to src/lib-storage/index/mbox/mbox-mail.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2008-05-26 09:51:01 UTC
  • mfrom: (1.10.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20080526095101-y0zxqc8ofd9j1aa5
Tags: 1:1.0.13-4ubuntu1
* Merge from debian unstable, remaining changes:
  - DebainMaintainerField
  - Use Snakeoil SSL certificate by default.
    + debian/control: Depend on ssl-cert
    + debian/patches/ssl-cert-snakeoil.dpatch: Change default SSL cert paths
      to snakeoil.
    + debian/dovecot-common.postinst: Relax grep for SSL_* a bit.
  - Fast TearDown:
    + debian/rules: Call dh_installinit in 'multiuser' mode.
    + debian/control: Depend on newer sysv-rc for this.
    + debian/dovecot-common.postinst: Remove stp script symlinks from rc0 and rc6 on upgrades.
      Need to be kept unil next LTS release.
  - Add autopkgtest in debian/tests/*.
  - Don't fail in postinst if dovecot-{sql,ldap} is missing. (LP: #153161)
  - Dropped upstream-mail-group-fixes.dpatch. No longer needed.
  - Dropped upstream-invalid-password-fixes.dpatch. No longer needed.
  - debian/dovecot-common.init: Check to see if there is an /etc/inetd.conf. (LP: #208411)
  - debian/patches/login-max-processes-count-warning.dpatch: Tell the user
    that they have reached the maxium number of processes count. (LP: #189616)

Show diffs side-by-side

added added

removed removed

Lines of Context:
157
157
        struct index_mail *mail = (struct index_mail *)_mail;
158
158
        struct index_mail_data *data = &mail->data;
159
159
        struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
160
 
        const struct mail_index_header *hdr;
161
160
        struct istream *input;
162
161
        struct message_size hdr_size;
163
 
        uoff_t size, body_offset, body_size, next_offset, old_offset;
164
 
        bool deleted;
 
162
        uoff_t size, body_offset, body_size, old_offset;
165
163
 
166
164
        size = index_mail_get_physical_size(_mail);
167
165
        if (size != (uoff_t)-1)
172
170
        input = mail_get_stream(_mail, &hdr_size, NULL);
173
171
        if (input == NULL)
174
172
                return (uoff_t)-1;
175
 
        i_stream_sync(mbox->mbox_stream);
176
173
 
177
174
        /* our header size varies, so don't do any caching */
178
175
        body_offset = istream_raw_mbox_get_body_offset(mbox->mbox_stream);
179
176
        if (body_offset == (uoff_t)-1)
180
177
                return (uoff_t)-1;
181
178
 
182
 
        /* use the next message's offset to avoid reading through the entire
183
 
           message body to find out its size */
184
 
        hdr = mail_index_get_header(mail->trans->trans_view);
185
 
        if (_mail->seq == hdr->messages_count) {
186
 
                /* last message, use the synced mbox size */
187
 
                int trailer_size;
188
 
 
189
 
                trailer_size = (STORAGE(mbox->storage)->flags &
190
 
                                MAIL_STORAGE_FLAG_SAVE_CRLF) != 0 ? 2 : 1;
191
 
 
192
 
                body_size = hdr->sync_size - body_offset - trailer_size;
193
 
        } else if (mbox_file_lookup_offset(mbox, mail->trans->trans_view,
194
 
                                           _mail->seq + 1, &next_offset,
195
 
                                           &deleted) > 0) {
196
 
                body_size = next_offset - body_offset;
197
 
        } else {
198
 
                body_size = (uoff_t)-1;
199
 
        }
200
 
 
201
179
        /* verify that the calculated body size is correct */
202
180
        body_size = istream_raw_mbox_get_body_size(mbox->mbox_stream,
203
 
                                                   body_size);
 
181
                                                   (uoff_t)-1);
204
182
 
205
183
        data->physical_size = hdr_size.physical_size + body_size;
206
 
        i_stream_seek(data->stream, old_offset);
207
 
        i_stream_sync(mbox->mbox_stream);
208
184
        return data->physical_size;
209
185
}
210
186