Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib-storage/index/maildir/maildir-mail.c @ 6280:eb7c9d8ece54 HEAD
mail_*() APIs changed to return int and return the actual data as pointer.
Changed some code to do error handling a bit better.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 12 Aug 2007 19:40:54 +0300 |
parents | 63b744cb99a4 |
children | 4a57baddc8b8 |
rev | line source |
---|---|
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
1 /* Copyright (C) 2003 Timo Sirainen */ |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 #include "lib.h" |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 #include "istream.h" |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
5 #include "index-mail.h" |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 #include "maildir-storage.h" |
5899
f29b93c0519c
Moved maildir filename related functions to maildir-filename.c
Timo Sirainen <tss@iki.fi>
parents:
5614
diff
changeset
|
7 #include "maildir-filename.h" |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 #include "maildir-uidlist.h" |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 |
5951
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
10 #include <stdlib.h> |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 #include <fcntl.h> |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
12 #include <unistd.h> |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 #include <sys/stat.h> |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 |
3279
b698ae839a18
Moved mbox/maildir-specific variables from struct index_mailbox to
Timo Sirainen <tss@iki.fi>
parents:
3248
diff
changeset
|
15 static int |
4907
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4677
diff
changeset
|
16 do_open(struct maildir_mailbox *mbox, const char *path, int *fd) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
18 *fd = open(path, O_RDONLY); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 if (*fd != -1) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 return 1; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
21 if (errno == ENOENT) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 return 0; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
23 |
5459
78eaf595359c
Removed struct index_storage abstraction. It's pointless.
Timo Sirainen <tss@iki.fi>
parents:
5452
diff
changeset
|
24 mail_storage_set_critical(&mbox->storage->storage, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
25 "open(%s) failed: %m", path); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
26 return -1; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
27 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
28 |
3279
b698ae839a18
Moved mbox/maildir-specific variables from struct index_mailbox to
Timo Sirainen <tss@iki.fi>
parents:
3248
diff
changeset
|
29 static int |
4907
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4677
diff
changeset
|
30 do_stat(struct maildir_mailbox *mbox, const char *path, struct stat *st) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
31 { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
32 if (stat(path, st) == 0) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
33 return 1; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
34 if (errno == ENOENT) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
35 return 0; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
36 |
5459
78eaf595359c
Removed struct index_storage abstraction. It's pointless.
Timo Sirainen <tss@iki.fi>
parents:
5452
diff
changeset
|
37 mail_storage_set_critical(&mbox->storage->storage, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
38 "stat(%s) failed: %m", path); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
39 return -1; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
40 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
41 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
42 static struct istream * |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
43 maildir_open_mail(struct maildir_mailbox *mbox, struct mail *mail, |
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
44 bool *deleted_r) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 { |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
46 const char *path; |
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
47 int fd = -1; |
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
48 |
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
49 *deleted_r = FALSE; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
50 |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
51 if (mail->uid != 0) { |
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
52 if (maildir_file_do(mbox, mail->uid, do_open, &fd) < 0) |
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
53 return NULL; |
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
54 } else { |
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
55 path = maildir_save_file_get_path(mail->transaction, mail->seq); |
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
56 if (do_open(mbox, path, &fd) <= 0) |
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
57 return NULL; |
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
58 } |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
59 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
60 if (fd == -1) { |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
61 *deleted_r = TRUE; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
62 return NULL; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
63 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
64 |
6162
896cc473c1f0
Renamed i_stream_create_file() to i_stream_create_fd().
Timo Sirainen <tss@iki.fi>
parents:
6142
diff
changeset
|
65 return i_stream_create_fd(fd, MAIL_READ_BLOCK_SIZE, TRUE); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
66 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
67 |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
68 static int maildir_mail_stat(struct mail *mail, struct stat *st) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
69 { |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
70 struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->box; |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
71 struct index_mail_data *data = &((struct index_mail *)mail)->data; |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
72 const char *path; |
6258
63b744cb99a4
If received date or physical size fetching fails because mail was expunged,
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
73 int fd, ret; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
74 |
3458
0c264f105899
Try to be a bit smarter about when to parse header/body.
Timo Sirainen <tss@iki.fi>
parents:
3418
diff
changeset
|
75 if (data->access_part != 0 && data->stream == NULL) { |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
2061
diff
changeset
|
76 /* we're going to open the mail anyway */ |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
77 struct istream *input; |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
78 |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
79 (void)mail_get_stream(mail, NULL, NULL, &input); |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
2061
diff
changeset
|
80 } |
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
2061
diff
changeset
|
81 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
82 if (data->stream != NULL) { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
83 fd = i_stream_get_fd(data->stream); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
84 i_assert(fd != -1); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
85 |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
86 if (fstat(fd, st) < 0) { |
5459
78eaf595359c
Removed struct index_storage abstraction. It's pointless.
Timo Sirainen <tss@iki.fi>
parents:
5452
diff
changeset
|
87 mail_storage_set_critical(&mbox->storage->storage, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
88 "fstat(maildir) failed: %m"); |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
89 return -1; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
90 } |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
91 } else if (mail->uid != 0) { |
6258
63b744cb99a4
If received date or physical size fetching fails because mail was expunged,
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
92 ret = maildir_file_do(mbox, mail->uid, do_stat, st); |
63b744cb99a4
If received date or physical size fetching fails because mail was expunged,
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
93 if (ret <= 0) { |
63b744cb99a4
If received date or physical size fetching fails because mail was expunged,
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
94 if (ret == 0) |
63b744cb99a4
If received date or physical size fetching fails because mail was expunged,
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
95 mail_set_expunged(mail); |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
96 return -1; |
6258
63b744cb99a4
If received date or physical size fetching fails because mail was expunged,
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
97 } |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
98 } else { |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
99 path = maildir_save_file_get_path(mail->transaction, mail->seq); |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
100 if (stat(path, st) < 0) { |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
101 mail_storage_set_critical(mail->box->storage, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
102 "stat(%s) failed: %m", path); |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
103 return -1; |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
104 } |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
105 } |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
106 return 0; |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
107 } |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
108 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
109 static int maildir_mail_get_received_date(struct mail *_mail, time_t *date_r) |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
110 { |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
111 struct index_mail *mail = (struct index_mail *)_mail; |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
112 struct index_mail_data *data = &mail->data; |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
113 struct stat st; |
4677 | 114 uint32_t t; |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
115 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
116 (void)index_mail_get_received_date(_mail, date_r); |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
117 if (*date_r != (time_t)-1) |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
118 return 0; |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
119 |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
120 if (maildir_mail_stat(_mail, &st) < 0) |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
121 return -1; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
122 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
123 *date_r = data->received_date = t = st.st_mtime; |
4672
b7ff8c64c436
We added received date as time_t instead of uint32_t which crashed with
Timo Sirainen <tss@iki.fi>
parents:
4461
diff
changeset
|
124 index_mail_cache_add(mail, MAIL_CACHE_RECEIVED_DATE, &t, sizeof(t)); |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
125 return 0; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
126 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
127 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
128 static int maildir_mail_get_save_date(struct mail *_mail, time_t *date_r) |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
129 { |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
130 struct index_mail *mail = (struct index_mail *)_mail; |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
131 struct index_mail_data *data = &mail->data; |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
132 struct stat st; |
5452 | 133 uint32_t t; |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
134 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
135 (void)index_mail_get_save_date(_mail, date_r); |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
136 if (*date_r != (time_t)-1) |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
137 return 0; |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
138 |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
139 if (maildir_mail_stat(_mail, &st) < 0) |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
140 return -1; |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
141 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
142 *date_r = data->save_date = t = st.st_ctime; |
5452 | 143 index_mail_cache_add(mail, MAIL_CACHE_SAVE_DATE, &t, sizeof(t)); |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
144 return data->save_date; |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
145 } |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
146 |
5908 | 147 static bool |
148 maildir_mail_get_fname(struct maildir_mailbox *mbox, struct mail *mail, | |
149 const char **fname_r) | |
150 { | |
151 enum maildir_uidlist_rec_flag flags; | |
152 | |
153 *fname_r = maildir_uidlist_lookup(mbox->uidlist, mail->uid, &flags); | |
154 if (*fname_r == NULL) { | |
155 mail_set_expunged(mail); | |
156 return FALSE; | |
157 } | |
158 return TRUE; | |
159 } | |
160 | |
5951
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
161 static int maildir_get_pop3_state(struct index_mail *mail) |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
162 { |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
163 const struct mail_cache_field *fields; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
164 unsigned int i, count, vsize_idx; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
165 enum mail_cache_decision_type dec, vsize_dec; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
166 enum mail_fetch_field allowed_pop3_fields; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
167 bool not_pop3_only = FALSE; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
168 |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
169 if (mail->pop3_state_set) |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
170 return mail->pop3_state; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
171 |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
172 /* if this mail itself has non-pop3 fields we know we're not |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
173 pop3-only */ |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
174 allowed_pop3_fields = MAIL_FETCH_FLAGS | MAIL_FETCH_STREAM_HEADER | |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
175 MAIL_FETCH_STREAM_BODY | MAIL_FETCH_UIDL_FILE_NAME | |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
176 MAIL_FETCH_VIRTUAL_SIZE; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
177 |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
178 if (mail->wanted_headers != NULL || |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
179 (mail->wanted_fields & allowed_pop3_fields) == 0) |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
180 not_pop3_only = TRUE; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
181 |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
182 /* get vsize decision */ |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
183 vsize_idx = mail->ibox->cache_fields[MAIL_CACHE_VIRTUAL_FULL_SIZE].idx; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
184 if (not_pop3_only) { |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
185 vsize_dec = mail_cache_field_get_decision(mail->ibox->cache, |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
186 vsize_idx); |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
187 vsize_dec &= ~MAIL_CACHE_DECISION_FORCED; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
188 } else { |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
189 /* also check if there are any non-vsize cached fields */ |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
190 vsize_dec = MAIL_CACHE_DECISION_NO; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
191 fields = mail_cache_register_get_list(mail->ibox->cache, |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
192 pool_datastack_create(), |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
193 &count); |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
194 for (i = 0; i < count; i++) { |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
195 dec = fields[i].decision & ~MAIL_CACHE_DECISION_FORCED; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
196 if (fields[i].idx == vsize_idx) |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
197 vsize_dec = dec; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
198 else if (dec != MAIL_CACHE_DECISION_NO) |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
199 not_pop3_only = TRUE; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
200 } |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
201 } |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
202 |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
203 if (!not_pop3_only) { |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
204 /* either nothing is cached, or only vsize is cached. */ |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
205 mail->pop3_state = 1; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
206 } else if (vsize_dec != MAIL_CACHE_DECISION_YES) { |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
207 /* if virtual size isn't cached permanently, |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
208 POP3 isn't being used */ |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
209 mail->pop3_state = -1; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
210 } else { |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
211 /* possibly a mixed pop3/imap */ |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
212 mail->pop3_state = 0; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
213 } |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
214 mail->pop3_state_set = TRUE; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
215 return mail->pop3_state; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
216 } |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
217 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
218 static int maildir_mail_get_virtual_size(struct mail *_mail, uoff_t *size_r) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
219 { |
2504
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
220 struct index_mail *mail = (struct index_mail *)_mail; |
3279
b698ae839a18
Moved mbox/maildir-specific variables from struct index_mailbox to
Timo Sirainen <tss@iki.fi>
parents:
3248
diff
changeset
|
221 struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
222 struct index_mail_data *data = &mail->data; |
5951
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
223 struct message_size hdr_size, body_size; |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
224 struct istream *input; |
5951
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
225 const char *path, *fname, *value; |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
226 uoff_t old_offset, size; |
5951
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
227 int pop3_state; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
228 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
229 if (index_mail_get_cached_virtual_size(mail, size_r)) |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
230 return 0; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
231 |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
232 if (_mail->uid != 0) { |
5908 | 233 if (!maildir_mail_get_fname(mbox, _mail, &fname)) |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
234 return -1; |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
235 } else { |
4450
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
236 path = maildir_save_file_get_path(_mail->transaction, |
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
237 _mail->seq); |
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
238 fname = strrchr(path, '/'); |
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
239 fname = fname != NULL ? fname + 1 : path; |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
240 } |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
241 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
242 /* size can be included in filename */ |
4351
61cc7e40bec6
Add ",S=size" to maildir filenames when quota plugin is loaded with
Timo Sirainen <tss@iki.fi>
parents:
4274
diff
changeset
|
243 if (maildir_filename_get_size(fname, MAILDIR_EXTRA_VIRTUAL_SIZE, |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
244 &data->virtual_size)) { |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
245 *size_r = data->virtual_size; |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
246 return 0; |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
247 } |
5951
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
248 |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
249 /* size can be included in uidlist entry */ |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
250 if (_mail->uid != 0) { |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
251 value = maildir_uidlist_lookup_ext(mbox->uidlist, _mail->uid, |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
252 MAILDIR_UIDLIST_REC_EXT_VSIZE); |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
253 if (value != NULL) { |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
254 char *p; |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
255 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
256 size = strtoull(value, &p, 10); |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
257 if (*p == '\0') { |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
258 data->virtual_size = *size_r = size; |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
259 return 0; |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
260 } |
5951
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
261 } |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
262 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
263 |
5951
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
264 /* fallback to reading the file */ |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
265 old_offset = data->stream == NULL ? 0 : data->stream->v_offset; |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
266 if (mail_get_stream(_mail, &hdr_size, &body_size, &input) < 0) |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
267 return -1; |
5951
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
268 i_stream_seek(data->stream, old_offset); |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
269 i_assert(data->virtual_size != (uoff_t)-1); |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
270 |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
271 /* 1 = pop3-only, 0 = mixed, -1 = no pop3 */ |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
272 pop3_state = maildir_get_pop3_state(mail); |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
273 if (pop3_state <= 0) { |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
274 index_mail_cache_add(mail, MAIL_CACHE_VIRTUAL_FULL_SIZE, |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
275 &data->virtual_size, |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
276 sizeof(data->virtual_size)); |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
277 } |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
278 if (pop3_state >= 0) { |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
279 /* if virtual size is wanted permanently, store it to uidlist |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
280 so that in case cache file gets lost we can get it quickly */ |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
281 maildir_uidlist_set_ext(mbox->uidlist, _mail->uid, |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
282 MAILDIR_UIDLIST_REC_EXT_VSIZE, |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
283 dec2str(data->virtual_size)); |
e9b5d3d33b95
Store virtual sizes to dovecot-uidlist if we want to use them all the time.
Timo Sirainen <tss@iki.fi>
parents:
5908
diff
changeset
|
284 } |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
285 *size_r = data->virtual_size; |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
286 return 0; |
2504
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
287 } |
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
288 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
289 static int |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
290 maildir_mail_get_special(struct mail *_mail, enum mail_fetch_field field, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
291 const char **value_r) |
2996
9219e788d774
Added %f pop3_uidl_format for maildir. Patch by Andrey Panin.
Timo Sirainen <tss@iki.fi>
parents:
2504
diff
changeset
|
292 { |
9219e788d774
Added %f pop3_uidl_format for maildir. Patch by Andrey Panin.
Timo Sirainen <tss@iki.fi>
parents:
2504
diff
changeset
|
293 struct index_mail *mail = (struct index_mail *)_mail; |
3279
b698ae839a18
Moved mbox/maildir-specific variables from struct index_mailbox to
Timo Sirainen <tss@iki.fi>
parents:
3248
diff
changeset
|
294 struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox; |
4450
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
295 const char *path, *fname, *end; |
2996
9219e788d774
Added %f pop3_uidl_format for maildir. Patch by Andrey Panin.
Timo Sirainen <tss@iki.fi>
parents:
2504
diff
changeset
|
296 |
9219e788d774
Added %f pop3_uidl_format for maildir. Patch by Andrey Panin.
Timo Sirainen <tss@iki.fi>
parents:
2504
diff
changeset
|
297 if (field == MAIL_FETCH_UIDL_FILE_NAME) { |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
298 if (_mail->uid != 0) { |
5908 | 299 if (!maildir_mail_get_fname(mbox, _mail, &fname)) |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
300 return -1; |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
301 } else { |
4450
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
302 path = maildir_save_file_get_path(_mail->transaction, |
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
303 _mail->seq); |
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
304 fname = strrchr(path, '/'); |
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
305 fname = fname != NULL ? fname + 1 : path; |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
306 } |
3417
b0bdf32564b7
Replaced ':' and ',' character usages with #defines, so they can be changed
Timo Sirainen <tss@iki.fi>
parents:
3280
diff
changeset
|
307 end = strchr(fname, MAILDIR_INFO_SEP); |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
308 *value_r = end == NULL ? fname : t_strdup_until(fname, end); |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
309 return 0; |
2996
9219e788d774
Added %f pop3_uidl_format for maildir. Patch by Andrey Panin.
Timo Sirainen <tss@iki.fi>
parents:
2504
diff
changeset
|
310 } |
9219e788d774
Added %f pop3_uidl_format for maildir. Patch by Andrey Panin.
Timo Sirainen <tss@iki.fi>
parents:
2504
diff
changeset
|
311 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
312 return index_mail_get_special(_mail, field, value_r); |
2996
9219e788d774
Added %f pop3_uidl_format for maildir. Patch by Andrey Panin.
Timo Sirainen <tss@iki.fi>
parents:
2504
diff
changeset
|
313 } |
9219e788d774
Added %f pop3_uidl_format for maildir. Patch by Andrey Panin.
Timo Sirainen <tss@iki.fi>
parents:
2504
diff
changeset
|
314 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
315 static int maildir_mail_get_physical_size(struct mail *_mail, uoff_t *size_r) |
2504
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
316 { |
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
317 struct index_mail *mail = (struct index_mail *)_mail; |
3279
b698ae839a18
Moved mbox/maildir-specific variables from struct index_mailbox to
Timo Sirainen <tss@iki.fi>
parents:
3248
diff
changeset
|
318 struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox; |
2504
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
319 struct index_mail_data *data = &mail->data; |
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
320 struct stat st; |
4450
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
321 const char *path, *fname; |
2504
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
322 uoff_t size; |
6258
63b744cb99a4
If received date or physical size fetching fails because mail was expunged,
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
323 int ret; |
2504
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
324 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
325 (void)index_mail_get_physical_size(_mail, size_r); |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
326 if (*size_r != (uoff_t)-1) |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
327 return 0; |
2504
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
328 |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
329 if (_mail->uid != 0) { |
5908 | 330 if (!maildir_mail_get_fname(mbox, _mail, &fname)) |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
331 return -1; |
4461
ce727f4e53e5
mail_get_physical_size() was broken with non-committed mails, which broke
Timo Sirainen <tss@iki.fi>
parents:
4455
diff
changeset
|
332 path = NULL; |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
333 } else { |
4450
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
334 path = maildir_save_file_get_path(_mail->transaction, |
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
335 _mail->seq); |
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
336 fname = strrchr(path, '/'); |
14b10f7ea70e
Don't break if mailbox path contains ':' characters.
Timo Sirainen <tss@iki.fi>
parents:
4421
diff
changeset
|
337 fname = fname != NULL ? fname + 1 : path; |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
338 } |
2504
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
339 |
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
340 /* size can be included in filename */ |
4351
61cc7e40bec6
Add ",S=size" to maildir filenames when quota plugin is loaded with
Timo Sirainen <tss@iki.fi>
parents:
4274
diff
changeset
|
341 if (!maildir_filename_get_size(fname, MAILDIR_EXTRA_FILE_SIZE, &size)) { |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
342 if (_mail->uid != 0) { |
6258
63b744cb99a4
If received date or physical size fetching fails because mail was expunged,
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
343 ret = maildir_file_do(mbox, _mail->uid, do_stat, &st); |
63b744cb99a4
If received date or physical size fetching fails because mail was expunged,
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
344 if (ret <= 0) { |
63b744cb99a4
If received date or physical size fetching fails because mail was expunged,
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
345 if (ret == 0) |
63b744cb99a4
If received date or physical size fetching fails because mail was expunged,
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
346 mail_set_expunged(_mail); |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
347 return -1; |
6258
63b744cb99a4
If received date or physical size fetching fails because mail was expunged,
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
348 } |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
349 } else { |
4351
61cc7e40bec6
Add ",S=size" to maildir filenames when quota plugin is loaded with
Timo Sirainen <tss@iki.fi>
parents:
4274
diff
changeset
|
350 /* saved mail which hasn't been committed yet */ |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
351 if (stat(path, &st) < 0) { |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
352 mail_storage_set_critical(_mail->box->storage, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
353 "stat(%s) failed: %m", path); |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
354 return -1; |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
355 } |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
356 } |
2504
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
357 size = st.st_size; |
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
358 } |
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
359 |
3909
411f20e72a8f
Added mail_cache_min_mail_count setting.
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
360 index_mail_cache_add(mail, MAIL_CACHE_PHYSICAL_FULL_SIZE, |
411f20e72a8f
Added mail_cache_min_mail_count setting.
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
361 &size, sizeof(size)); |
2504
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
362 data->physical_size = size; |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
363 *size_r = size; |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
364 return 0; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
365 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
366 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
367 static int maildir_mail_get_stream(struct mail *_mail, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
368 struct message_size *hdr_size, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
369 struct message_size *body_size, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
370 struct istream **stream_r) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
371 { |
3279
b698ae839a18
Moved mbox/maildir-specific variables from struct index_mailbox to
Timo Sirainen <tss@iki.fi>
parents:
3248
diff
changeset
|
372 struct index_mail *mail = (struct index_mail *)_mail; |
b698ae839a18
Moved mbox/maildir-specific variables from struct index_mailbox to
Timo Sirainen <tss@iki.fi>
parents:
3248
diff
changeset
|
373 struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
374 struct index_mail_data *data = &mail->data; |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3458
diff
changeset
|
375 bool deleted; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
376 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
377 if (data->stream == NULL) { |
4094
03e14e3a4610
Support accessing saved mails that haven't been committed yet (fixes quota for maildir).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4088
diff
changeset
|
378 data->stream = maildir_open_mail(mbox, _mail, &deleted); |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
2061
diff
changeset
|
379 if (data->stream == NULL) { |
5614
a4e5053fb31a
Added MAIL_ERROR_EXPUNGED. Set the error whenever expunged message is tried
Timo Sirainen <tss@iki.fi>
parents:
5459
diff
changeset
|
380 if (deleted) |
a4e5053fb31a
Added MAIL_ERROR_EXPUNGED. Set the error whenever expunged message is tried
Timo Sirainen <tss@iki.fi>
parents:
5459
diff
changeset
|
381 mail_set_expunged(_mail); |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
382 return -1; |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
2061
diff
changeset
|
383 } |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
384 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
385 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6258
diff
changeset
|
386 return index_mail_init_stream(mail, hdr_size, body_size, stream_r); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
387 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
388 |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3207
diff
changeset
|
389 struct mail_vfuncs maildir_mail_vfuncs = { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3207
diff
changeset
|
390 index_mail_free, |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3207
diff
changeset
|
391 index_mail_set_seq, |
4274
bd519db7f6e5
Added mail_set_uid() to select a mail by UID.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4094
diff
changeset
|
392 index_mail_set_uid, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
393 |
2317
0cf316c77b1b
Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
394 index_mail_get_flags, |
3016
61c8d205d887
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents:
2996
diff
changeset
|
395 index_mail_get_keywords, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
396 index_mail_get_parts, |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
397 index_mail_get_date, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
398 maildir_mail_get_received_date, |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4450
diff
changeset
|
399 maildir_mail_get_save_date, |
2504
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
400 maildir_mail_get_virtual_size, |
98f6057f27a1
Added mail.get_physical_size().
Timo Sirainen <tss@iki.fi>
parents:
2317
diff
changeset
|
401 maildir_mail_get_physical_size, |
3248
ff47e78ad717
Renamed mail_get_header() to mail_get_first_header() and mail_gets_headers()
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
402 index_mail_get_first_header, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
403 index_mail_get_headers, |
3248
ff47e78ad717
Renamed mail_get_header() to mail_get_first_header() and mail_gets_headers()
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
404 index_mail_get_header_stream, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
405 maildir_mail_get_stream, |
2996
9219e788d774
Added %f pop3_uidl_format for maildir. Patch by Andrey Panin.
Timo Sirainen <tss@iki.fi>
parents:
2504
diff
changeset
|
406 maildir_mail_get_special, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
407 index_mail_update_flags, |
3016
61c8d205d887
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents:
2996
diff
changeset
|
408 index_mail_update_keywords, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
409 index_mail_expunge |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
410 }; |