]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Storage backend sync_init()s no longer need to check if mailbox is open
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 10 Jul 2017 11:20:50 +0000 (14:20 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 12 Jul 2017 21:21:49 +0000 (00:21 +0300)
The previous change guarantees it.

src/lib-storage/index/cydir/cydir-sync.c
src/lib-storage/index/dbox-multi/mdbox-deleted-storage.c
src/lib-storage/index/dbox-multi/mdbox-sync.c
src/lib-storage/index/dbox-single/sdbox-sync.c
src/lib-storage/index/imapc/imapc-sync.c
src/lib-storage/index/maildir/maildir-sync.c
src/lib-storage/index/mbox/mbox-sync.c
src/lib-storage/index/pop3c/pop3c-sync.c
src/lib-storage/index/raw/raw-sync.c

index 371001a8304983993997ff349a457555302499fb..7dc9a6b0ef809ef1138d51362cc81f85de419465 100644 (file)
@@ -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);
index 010a070559d0c5c6eb8dcc9170249b4cde03ef80..0db9d04a800934b78b22418ab1027e97c80bae97 100644 (file)
@@ -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);
index 84f5af7c773ac4339518042953d96bdf609b7e72..76f02183ec1717df12e1e29da1cd21a82e29173c 100644 (file)
@@ -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);
index 889f85e5912f3ecddbc9863cf1ecddaf7a9869cd..430d8d0f799fc0fe44e42a78589173caa8490d52 100644 (file)
@@ -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);
index 1e07e4a4e473e5b7064b5940f76f4b1c25417783..52092f31d1140c91599383696b56c1bf52651b02 100644 (file)
@@ -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;
index 8342df10cc9587e49f64e957e3077f094393798d..91b7eedfc0ae0b840c85c43d3f52520b9d897556 100644 (file)
@@ -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,
index 9c29734b63795e5ec6e00b5e0c434a22b8cc80a2..f34d755474fc3d4bd9fdfd458f290a5eb2bf1e5f 100644 (file)
@@ -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;
index 4751d9eb3bd46f02b9a2055b1184665a78bbfdf8..1a4b3123733b588665bb33400d8e24bbbc95ed72 100644 (file)
@@ -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);
 }
index 1b77498243550b8a3e31c02840c9d5e08b8d442b..277a20131aecc9538caac23e5ca93a3d8ec624ee 100644 (file)
@@ -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);