Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/lib-index/mail-index-util.c @ 160:ff05b320482c HEAD
Bigger changes.. full_virtual_size was removed from index record and
MessagePart caching is now forced. Also added per-message flags, including
binary flags which can be used to check if CRs need to be inserted into
message data.
Added mbox-rewrite support which can be used to write out mbox file with
updated flags. This still has the problem of being able to read changed
custom flags, that'll require another bigger change.
There's also several other mostly mbox related fixes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 06 Sep 2002 16:43:58 +0300 |
parents | 3b1985cbc908 |
children | db6e288be0e9 |
comparison
equal
deleted
inserted
replaced
159:e0193106a95d | 160:ff05b320482c |
---|---|
1 /* Copyright (C) 2002 Timo Sirainen */ | 1 /* Copyright (C) 2002 Timo Sirainen */ |
2 | 2 |
3 #include "lib.h" | 3 #include "lib.h" |
4 #include "iobuffer.h" | |
4 #include "hostpid.h" | 5 #include "hostpid.h" |
6 #include "message-size.h" | |
7 #include "message-part-serialize.h" | |
5 #include "mail-index.h" | 8 #include "mail-index.h" |
6 #include "mail-index-util.h" | 9 #include "mail-index-util.h" |
7 | 10 |
8 #include <unistd.h> | 11 #include <unistd.h> |
9 #include <fcntl.h> | 12 #include <fcntl.h> |
55 index_set_error(index, "Can't create temp index %s: %m", *path); | 58 index_set_error(index, "Can't create temp index %s: %m", *path); |
56 | 59 |
57 return fd; | 60 return fd; |
58 } | 61 } |
59 | 62 |
63 | |
64 int mail_index_get_virtual_size(MailIndex *index, MailIndexRecord *rec, | |
65 int fastscan, uoff_t *virtual_size) | |
66 { | |
67 MessageSize hdr_size, body_size; | |
68 IOBuffer *inbuf; | |
69 const void *part_data; | |
70 unsigned int size; | |
71 | |
72 if ((rec->index_flags & INDEX_MAIL_FLAG_BINARY_HEADER) && | |
73 (rec->index_flags & INDEX_MAIL_FLAG_BINARY_BODY)) { | |
74 /* virtual size == physical size */ | |
75 *virtual_size += rec->header_size + rec->body_size; | |
76 return TRUE; | |
77 } | |
78 | |
79 part_data = index->lookup_field_raw(index, rec, | |
80 FIELD_TYPE_MESSAGEPART, &size); | |
81 if (part_data != NULL) { | |
82 /* get sizes from preparsed message structure */ | |
83 if (!message_part_deserialize_size(part_data, size, | |
84 &hdr_size, &body_size)) { | |
85 /* corrupted, ignore */ | |
86 index_set_error(index, "Error in index file %s: " | |
87 "Corrupted cached MessagePart data", | |
88 index->filepath); | |
89 } else { | |
90 *virtual_size = hdr_size.virtual_size + | |
91 body_size.virtual_size; | |
92 return TRUE; | |
93 } | |
94 } | |
95 | |
96 /* only way left is to actually parse the message */ | |
97 *virtual_size = 0; | |
98 | |
99 if (fastscan) { | |
100 /* and we don't want that */ | |
101 return FALSE; | |
102 } | |
103 | |
104 inbuf = index->open_mail(index, rec); | |
105 if (inbuf == NULL) | |
106 return FALSE; | |
107 | |
108 /* we don't care about the difference in header/body, | |
109 so parse the whole message as a "body" */ | |
110 message_get_body_size(inbuf, &body_size, (uoff_t)-1); | |
111 *virtual_size = body_size.virtual_size; | |
112 | |
113 (void)close(inbuf->fd); | |
114 io_buffer_destroy(inbuf); | |
115 return TRUE; | |
116 } |