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)
{
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. */
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;
}