From: Timo Sirainen Date: Mon, 10 Jul 2017 11:20:50 +0000 (+0300) Subject: lib-storage: Storage backend sync_init()s no longer need to check if mailbox is open X-Git-Tag: 2.2.32.rc1~118 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=40d0717afb789ff37d06205bddaa2c707bc5f787;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Storage backend sync_init()s no longer need to check if mailbox is open The previous change guarantees it. --- diff --git a/src/lib-storage/index/cydir/cydir-sync.c b/src/lib-storage/index/cydir/cydir-sync.c index 371001a830..7dc9a6b0ef 100644 --- a/src/lib-storage/index/cydir/cydir-sync.c +++ b/src/lib-storage/index/cydir/cydir-sync.c @@ -165,12 +165,7 @@ cydir_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) struct cydir_mailbox *mbox = (struct cydir_mailbox *)box; int ret = 0; - if (!box->opened) { - if (mailbox_open(box) < 0) - ret = -1; - } - - if (index_mailbox_want_full_sync(&mbox->box, flags) && ret == 0) + if (index_mailbox_want_full_sync(&mbox->box, flags)) ret = cydir_sync(mbox); return index_mailbox_sync_init(box, flags, ret < 0); diff --git a/src/lib-storage/index/dbox-multi/mdbox-deleted-storage.c b/src/lib-storage/index/dbox-multi/mdbox-deleted-storage.c index 010a070559..0db9d04a80 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-deleted-storage.c +++ b/src/lib-storage/index/dbox-multi/mdbox-deleted-storage.c @@ -230,13 +230,8 @@ mdbox_deleted_storage_sync_init(struct mailbox *box, enum mdbox_sync_flags mdbox_sync_flags = 0; int ret = 0; - if (!box->opened) { - if (mailbox_open(box) < 0) - ret = -1; - } - - if (ret == 0 && (index_mailbox_want_full_sync(&mbox->box, flags) || - mbox->storage->corrupted)) + if (index_mailbox_want_full_sync(&mbox->box, flags) || + mbox->storage->corrupted) ret = mdbox_deleted_sync(mbox, mdbox_sync_flags); return index_mailbox_sync_init(box, flags, ret < 0); diff --git a/src/lib-storage/index/dbox-multi/mdbox-sync.c b/src/lib-storage/index/dbox-multi/mdbox-sync.c index 84f5af7c77..76f02183ec 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-sync.c +++ b/src/lib-storage/index/dbox-multi/mdbox-sync.c @@ -359,17 +359,10 @@ mdbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) enum mdbox_sync_flags mdbox_sync_flags = 0; int ret = 0; - if (!box->opened) { - if (mailbox_open(box) < 0) - ret = -1; - } - - if (box->opened) { - if (mail_index_reset_fscked(box->index)) - mdbox_storage_set_corrupted(mbox->storage); - } - if (ret == 0 && (index_mailbox_want_full_sync(&mbox->box, flags) || - mbox->storage->corrupted)) { + if (mail_index_reset_fscked(box->index)) + mdbox_storage_set_corrupted(mbox->storage); + if (index_mailbox_want_full_sync(&mbox->box, flags) || + mbox->storage->corrupted) { if ((flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0) mdbox_sync_flags |= MDBOX_SYNC_FLAG_FORCE_REBUILD; ret = mdbox_sync(mbox, mdbox_sync_flags); diff --git a/src/lib-storage/index/dbox-single/sdbox-sync.c b/src/lib-storage/index/dbox-single/sdbox-sync.c index 889f85e591..430d8d0f79 100644 --- a/src/lib-storage/index/dbox-single/sdbox-sync.c +++ b/src/lib-storage/index/dbox-single/sdbox-sync.c @@ -312,15 +312,10 @@ sdbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) enum sdbox_sync_flags sdbox_sync_flags = 0; int ret = 0; - if (!box->opened) { - if (mailbox_open(box) < 0) - ret = -1; - } - - if (ret == 0 && mail_index_reset_fscked(box->index)) + if (mail_index_reset_fscked(box->index)) sdbox_set_mailbox_corrupted(box); - if (ret == 0 && (index_mailbox_want_full_sync(&mbox->box, flags) || - mbox->corrupted_rebuild_count != 0)) { + if (index_mailbox_want_full_sync(&mbox->box, flags) || + mbox->corrupted_rebuild_count != 0) { if ((flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0) sdbox_sync_flags |= SDBOX_SYNC_FLAG_FORCE_REBUILD; ret = sdbox_sync(mbox, sdbox_sync_flags); diff --git a/src/lib-storage/index/imapc/imapc-sync.c b/src/lib-storage/index/imapc/imapc-sync.c index 1e07e4a4e4..52092f31d1 100644 --- a/src/lib-storage/index/imapc/imapc-sync.c +++ b/src/lib-storage/index/imapc/imapc-sync.c @@ -675,13 +675,7 @@ imapc_mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) list->refreshed_mailboxes_recently = FALSE; } - if (!box->opened) { - if (mailbox_open(box) < 0) - ret = -1; - } - - if (ret == 0) - imapc_noop_if_needed(mbox, flags); + imapc_noop_if_needed(mbox, flags); if (imapc_mailbox_commit_delayed_trans(mbox, &changes) < 0) ret = -1; diff --git a/src/lib-storage/index/maildir/maildir-sync.c b/src/lib-storage/index/maildir/maildir-sync.c index 8342df10cc..91b7eedfc0 100644 --- a/src/lib-storage/index/maildir/maildir-sync.c +++ b/src/lib-storage/index/maildir/maildir-sync.c @@ -1087,11 +1087,6 @@ maildir_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) bool lost_files, force_resync; int ret = 0; - if (!box->opened) { - if (mailbox_open(box) < 0) - return index_mailbox_sync_init(box, flags, TRUE); - } - force_resync = (flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0; if (index_mailbox_want_full_sync(&mbox->box, flags)) { ret = maildir_sync_run(mbox, flags, force_resync, diff --git a/src/lib-storage/index/mbox/mbox-sync.c b/src/lib-storage/index/mbox/mbox-sync.c index 9c29734b63..f34d755474 100644 --- a/src/lib-storage/index/mbox/mbox-sync.c +++ b/src/lib-storage/index/mbox/mbox-sync.c @@ -2043,12 +2043,7 @@ mbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) enum mbox_sync_flags mbox_sync_flags = 0; int ret = 0; - if (!box->opened) { - if (mailbox_open(box) < 0) - ret = -1; - } - - if (index_mailbox_want_full_sync(&mbox->box, flags) && ret == 0) { + if (index_mailbox_want_full_sync(&mbox->box, flags)) { if ((flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0 && !mbox->storage->set->mbox_very_dirty_syncs) mbox_sync_flags |= MBOX_SYNC_UNDIRTY; diff --git a/src/lib-storage/index/pop3c/pop3c-sync.c b/src/lib-storage/index/pop3c/pop3c-sync.c index 4751d9eb3b..1a4b312373 100644 --- a/src/lib-storage/index/pop3c/pop3c-sync.c +++ b/src/lib-storage/index/pop3c/pop3c-sync.c @@ -351,18 +351,11 @@ pop3c_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box; int ret = 0; - if (!box->opened) { - if (mailbox_open(box) < 0) - ret = -1; - } else { - if ((flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0 && - mbox->msg_uidls == NULL) { - /* FIXME: reconnect */ - } + if ((flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0 && + mbox->msg_uidls == NULL) { + /* FIXME: reconnect */ } - if (ret == 0) - ret = pop3c_sync(mbox); - + ret = pop3c_sync(mbox); return index_mailbox_sync_init(box, flags, ret < 0); } diff --git a/src/lib-storage/index/raw/raw-sync.c b/src/lib-storage/index/raw/raw-sync.c index 1b77498243..277a20131a 100644 --- a/src/lib-storage/index/raw/raw-sync.c +++ b/src/lib-storage/index/raw/raw-sync.c @@ -59,12 +59,7 @@ raw_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) struct raw_mailbox *mbox = (struct raw_mailbox *)box; int ret = 0; - if (!box->opened) { - if (mailbox_open(box) < 0) - ret = -1; - } - - if (!mbox->synced && ret == 0) + if (!mbox->synced) ret = raw_sync(mbox); return index_mailbox_sync_init(box, flags, ret < 0);