dovecot-2.0: dbox: Added dbox_file_get_plaintext_size() for easi...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Dec 3 12:15:51 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/251612ef4186
changeset: 12505:251612ef4186
user: Timo Sirainen <tss at iki.fi>
date: Fri Dec 03 10:15:20 2010 +0000
description:
dbox: Added dbox_file_get_plaintext_size() for easily getting it.
diffstat:
src/lib-storage/index/dbox-common/dbox-file.c | 16 ++++++++++++++++
src/lib-storage/index/dbox-common/dbox-file.h | 4 ++++
src/lib-storage/index/dbox-common/dbox-mail.c | 10 +---------
3 files changed, 21 insertions(+), 9 deletions(-)
diffs (67 lines):
diff -r c6b0e643d2dc -r 251612ef4186 src/lib-storage/index/dbox-common/dbox-file.c
--- a/src/lib-storage/index/dbox-common/dbox-file.c Fri Dec 03 10:05:38 2010 +0000
+++ b/src/lib-storage/index/dbox-common/dbox-file.c Fri Dec 03 10:15:20 2010 +0000
@@ -685,6 +685,22 @@
return NULL;
}
+uoff_t dbox_file_get_plaintext_size(struct dbox_file *file)
+{
+ const char *value;
+
+ i_assert(file->metadata_read_offset == file->cur_offset);
+
+ /* see if we have it in metadata */
+ value = dbox_file_metadata_get(file, DBOX_METADATA_PHYSICAL_SIZE);
+ if (value != NULL)
+ return strtoul(value, NULL, 16);
+ else {
+ /* no. that means we can use the size in the header */
+ return file->cur_physical_size;
+ }
+}
+
void dbox_msg_header_fill(struct dbox_message_header *dbox_msg_hdr,
uoff_t message_size)
{
diff -r c6b0e643d2dc -r 251612ef4186 src/lib-storage/index/dbox-common/dbox-file.h
--- a/src/lib-storage/index/dbox-common/dbox-file.h Fri Dec 03 10:05:38 2010 +0000
+++ b/src/lib-storage/index/dbox-common/dbox-file.h Fri Dec 03 10:15:20 2010 +0000
@@ -183,6 +183,10 @@
const char *dbox_file_metadata_get(struct dbox_file *file,
enum dbox_metadata_key key);
+/* Returns DBOX_METADATA_PHYSICAL_SIZE if set, otherwise physical size from
+ header. They differ only for e.g. compressed mails. */
+uoff_t dbox_file_get_plaintext_size(struct dbox_file *file);
+
/* Fix a broken dbox file by rename()ing over it with a fixed file. Everything
before start_offset is assumed to be valid and is simply copied. The file
is reopened afterwards. Returns 0 if ok, -1 if I/O error. */
diff -r c6b0e643d2dc -r 251612ef4186 src/lib-storage/index/dbox-common/dbox-mail.c
--- a/src/lib-storage/index/dbox-common/dbox-mail.c Fri Dec 03 10:05:38 2010 +0000
+++ b/src/lib-storage/index/dbox-common/dbox-mail.c Fri Dec 03 10:15:20 2010 +0000
@@ -79,22 +79,14 @@
struct dbox_mail *mail = (struct dbox_mail *)_mail;
struct index_mail_data *data = &mail->imail.data;
struct dbox_file *file;
- const char *value;
if (index_mail_get_physical_size(_mail, size_r) == 0)
return 0;
- /* see if we have it in metadata */
if (dbox_mail_metadata_read(mail, &file) < 0)
return -1;
- value = dbox_file_metadata_get(file, DBOX_METADATA_PHYSICAL_SIZE);
- if (value != NULL)
- data->physical_size = strtoul(value, NULL, 16);
- else {
- /* no. that means we can use the size in the header */
- data->physical_size = file->cur_physical_size;
- }
+ data->physical_size = dbox_file_get_plaintext_size(file);
*size_r = data->physical_size;
return 0;
}
More information about the dovecot-cvs
mailing list