comparison src/plugins/lazy-expunge/lazy-expunge-plugin.c @ 12585:b748c622e896

lib-storage: Added mailbox_get_last_*error() wrappers and use them.
author Timo Sirainen <tss@iki.fi>
date Thu, 20 Jan 2011 19:21:20 +0200
parents 57d7ea7fa5f6
children 82f984d7a241
comparison
equal deleted inserted replaced
12584:8dbcf27f7c08 12585:b748c622e896
81 if (mailbox_open(box) == 0) { 81 if (mailbox_open(box) == 0) {
82 *error_r = NULL; 82 *error_r = NULL;
83 return box; 83 return box;
84 } 84 }
85 85
86 *error_r = mail_storage_get_last_error(mailbox_get_storage(box), 86 *error_r = mailbox_get_last_error(box, &error);
87 &error);
88 if (error != MAIL_ERROR_NOTFOUND) { 87 if (error != MAIL_ERROR_NOTFOUND) {
89 mailbox_free(&box); 88 mailbox_free(&box);
90 return NULL; 89 return NULL;
91 } 90 }
92 91
93 /* try creating and re-opening it. */ 92 /* try creating and re-opening it. */
94 if (mailbox_create(box, NULL, FALSE) < 0 || 93 if (mailbox_create(box, NULL, FALSE) < 0 ||
95 mailbox_open(box) < 0) { 94 mailbox_open(box) < 0) {
96 *error_r = mail_storage_get_last_error(mailbox_get_storage(box), 95 *error_r = mailbox_get_last_error(box, NULL);
97 NULL);
98 mailbox_free(&box); 96 mailbox_free(&box);
99 return NULL; 97 return NULL;
100 } 98 }
101 return box; 99 return box;
102 } 100 }
261 259
262 if (ret == 0) 260 if (ret == 0)
263 break; 261 break;
264 mailbox_free(&dest_box); 262 mailbox_free(&dest_box);
265 263
266 mail_storage_get_last_error(src_box->storage, &error); 264 error = mailbox_get_last_mail_error(src_box);
267 switch (error) { 265 switch (error) {
268 case MAIL_ERROR_EXISTS: 266 case MAIL_ERROR_EXISTS:
269 break; 267 break;
270 case MAIL_ERROR_NOTFOUND: 268 case MAIL_ERROR_NOTFOUND:
271 return 0; 269 return 0;
290 struct mailbox_transaction_context *src_trans, *dest_trans; 288 struct mailbox_transaction_context *src_trans, *dest_trans;
291 struct mail_search_context *search_ctx; 289 struct mail_search_context *search_ctx;
292 struct mail_save_context *save_ctx; 290 struct mail_save_context *save_ctx;
293 struct mail *mail; 291 struct mail *mail;
294 const char *errstr; 292 const char *errstr;
295 enum mail_error error;
296 int ret; 293 int ret;
297 294
298 dest_box = mailbox_alloc(src_box->list, dest_name, 0); 295 dest_box = mailbox_alloc(src_box->list, dest_name, 0);
299 if (mailbox_open(dest_box) < 0) { 296 if (mailbox_open(dest_box) < 0) {
300 errstr = mail_storage_get_last_error(dest_box->storage, &error); 297 errstr = mailbox_get_last_error(dest_box, NULL);
301 i_error("lazy_expunge: Couldn't open DELETE dest mailbox " 298 i_error("lazy_expunge: Couldn't open DELETE dest mailbox "
302 "%s: %s", dest_name, errstr); 299 "%s: %s", dest_name, errstr);
303 mailbox_free(&dest_box); 300 mailbox_free(&dest_box);
304 return -1; 301 return -1;
305 } 302 }
364 LAZY_EXPUNGE_LIST_CONTEXT(box->list); 361 LAZY_EXPUNGE_LIST_CONTEXT(box->list);
365 struct mailbox_list *list = box->list; 362 struct mailbox_list *list = box->list;
366 struct mail_namespace *expunge_ns, *dest_ns; 363 struct mail_namespace *expunge_ns, *dest_ns;
367 struct mailbox *expunge_box; 364 struct mailbox *expunge_box;
368 const char *destname, *str; 365 const char *destname, *str;
369 enum mail_error error;
370 struct tm *tm; 366 struct tm *tm;
371 char timestamp[256]; 367 char timestamp[256];
372 int ret; 368 int ret;
373 369
374 if (llist->internal_namespace || !box->opened) { 370 if (llist->internal_namespace || !box->opened) {
410 406
411 /* other sessions now see the mailbox completely deleted. 407 /* other sessions now see the mailbox completely deleted.
412 since it's not really deleted in the lazy-expunge namespace, 408 since it's not really deleted in the lazy-expunge namespace,
413 we might want to change it again. so mark the index undeleted. */ 409 we might want to change it again. so mark the index undeleted. */
414 if (mailbox_open(expunge_box) < 0) { 410 if (mailbox_open(expunge_box) < 0) {
415 str = mail_storage_get_last_error(expunge_box->storage, &error); 411 str = mailbox_get_last_error(expunge_box, NULL);
416 i_error("lazy_expunge: Couldn't open DELETEd mailbox " 412 i_error("lazy_expunge: Couldn't open DELETEd mailbox "
417 "%s: %s", expunge_box->name, str); 413 "%s: %s", expunge_box->name, str);
418 mailbox_free(&expunge_box); 414 mailbox_free(&expunge_box);
419 return -1; 415 return -1;
420 } 416 }