Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/plugins/trash/trash-plugin.c @ 5188:519ab252f1a3 HEAD
Fixes for handling multiple storages.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 22 Feb 2007 17:38:43 +0200 |
parents | 9dd18b285223 |
children | 7ec060a7c29f |
comparison
equal
deleted
inserted
replaced
5187:9dd18b285223 | 5188:519ab252f1a3 |
---|---|
55 static int trash_clean_mailbox_open(struct trash_mailbox *trash) | 55 static int trash_clean_mailbox_open(struct trash_mailbox *trash) |
56 { | 56 { |
57 trash->box = mailbox_open(trash->storage, trash->name, NULL, | 57 trash->box = mailbox_open(trash->storage, trash->name, NULL, |
58 MAILBOX_OPEN_KEEP_RECENT); | 58 MAILBOX_OPEN_KEEP_RECENT); |
59 if (trash->box == NULL) | 59 if (trash->box == NULL) |
60 return -1; | 60 return 0; |
61 | 61 |
62 if (sync_mailbox(trash->box) < 0) | 62 if (sync_mailbox(trash->box) < 0) |
63 return -1; | 63 return -1; |
64 | 64 |
65 trash->trans = mailbox_transaction_begin(trash->box, 0); | 65 trash->trans = mailbox_transaction_begin(trash->box, 0); |
81 if (trash->box == NULL) | 81 if (trash->box == NULL) |
82 ret = trash_clean_mailbox_open(trash); | 82 ret = trash_clean_mailbox_open(trash); |
83 else | 83 else |
84 ret = mailbox_search_next(trash->search_ctx, | 84 ret = mailbox_search_next(trash->search_ctx, |
85 trash->mail); | 85 trash->mail); |
86 if (ret <= 0) | 86 if (ret <= 0) { |
87 *received_time_r = 0; | |
87 return ret; | 88 return ret; |
88 | 89 } |
89 trash->mail_set = TRUE; | 90 trash->mail_set = TRUE; |
90 } | 91 } |
91 | 92 |
92 *received_time_r = mail_get_received_date(trash->mail); | 93 *received_time_r = mail_get_received_date(trash->mail); |
93 return 1; | 94 return 1; |
102 uint64_t size, size_expunged = 0, expunged_count = 0; | 103 uint64_t size, size_expunged = 0, expunged_count = 0; |
103 int ret = 0; | 104 int ret = 0; |
104 | 105 |
105 trashes = array_get_modifiable(&trash_boxes, &count); | 106 trashes = array_get_modifiable(&trash_boxes, &count); |
106 for (i = 0; i < count; ) { | 107 for (i = 0; i < count; ) { |
107 if (trashes[i].storage == NULL) { | |
108 /* FIXME: this is really ugly. it'll do however until | |
109 we get proper namespace support for lib-storage. */ | |
110 struct mail_storage *const *storage; | |
111 | |
112 storage = array_idx("a_set->storages, 0); | |
113 trashes[i].storage = *storage; | |
114 } | |
115 /* expunge oldest mails first in all trash boxes with | 108 /* expunge oldest mails first in all trash boxes with |
116 same priority */ | 109 same priority */ |
117 oldest_idx = count; | 110 oldest_idx = count; |
118 oldest = (time_t)-1; | 111 oldest = (time_t)-1; |
119 for (j = i; j < count; j++) { | 112 for (j = i; j < count; j++) { |
120 if (trashes[j].priority != trashes[j].priority) | 113 if (trashes[j].priority != trashes[j].priority) |
121 break; | 114 break; |
122 | 115 |
123 ret = trash_clean_mailbox_get_next(&trashes[i], | 116 if (trashes[j].storage == NULL) { |
117 /* FIXME: this is really ugly. it'll do however | |
118 until we get proper namespace support for | |
119 lib-storage. */ | |
120 struct mail_storage *const *storage; | |
121 | |
122 storage = array_idx("a_set->storages, 0); | |
123 trashes[j].storage = *storage; | |
124 } | |
125 | |
126 ret = trash_clean_mailbox_get_next(&trashes[j], | |
124 &received); | 127 &received); |
125 if (ret < 0) | 128 if (ret < 0) |
126 goto __err; | 129 goto __err; |
127 if (ret > 0) { | 130 if (ret > 0) { |
128 if (oldest == (time_t)-1 || | 131 if (oldest == (time_t)-1 || received < oldest) { |
129 received < oldest) { | |
130 oldest = received; | 132 oldest = received; |
131 oldest_idx = j; | 133 oldest_idx = j; |
132 } | 134 } |
133 } | 135 } |
134 } | 136 } |