]> 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 <tss@dovecot.fi>
Mon, 10 Jul 2017 13:20:41 +0000 (16:20 +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 49eb6d4512ef43454b16fcdde893307512e28a46..200601f167e1882aefeb5f536782204413b78267 100644 (file)
@@ -166,12 +166,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 c655a4e5df48345485fd6a6e0f2feb07b50744dd..583d8f3833ecd06a0c33a7823518d680f386f433 100644 (file)
@@ -360,17 +360,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 62d8d2ca452791b67f5cd37b64ec2169c2c40987..58409bcaa4f7f37bb7ad9223ffee83decd42025c 100644 (file)
@@ -313,15 +313,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 3a3d9b95fd41da64ebe699dd6406c47c51bb9138..b1f597471402b914baf1b5f3539f3edc1db84fc7 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 13c233ff6277a793e6f95beb432e5c7b5be78a17..58a00e916e424fb556e3f4ff6d2aaeeabd676e8a 100644 (file)
@@ -2046,12 +2046,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 27ebfd05981db0af7501740f22528a1a72a39d5c..1bb996735770650f1fb7c803071b59993083bb2a 100644 (file)
@@ -353,18 +353,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 ea6402dceadbd6b7581785a457065a709f41c979..e7c68954b30caf77b908a93a7e935a56b8e6dcad 100644 (file)
@@ -60,12 +60,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);