From: Josef 'Jeff' Sipek Date: Tue, 22 Nov 2016 15:21:24 +0000 (-0500) Subject: lib-storage: require MAIL_STORAGE_CLASS_FLAG_STUBS when caching X-Git-Tag: 2.2.27~72 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1df777483912319a01110df6f8f48d1e84ff92ad;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: require MAIL_STORAGE_CLASS_FLAG_STUBS when caching If we are going to be using the storage for caching, we should check that the storage actually supports mail stubs. --- diff --git a/src/lib-storage/index/dbox-single/sdbox-storage.c b/src/lib-storage/index/dbox-single/sdbox-storage.c index cb268cc187..2c4ce1d730 100644 --- a/src/lib-storage/index/dbox-single/sdbox-storage.c +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c @@ -405,7 +405,8 @@ struct mail_storage sdbox_storage = { .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG | MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS | MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS | - MAIL_STORAGE_CLASS_FLAG_BINARY_DATA, + MAIL_STORAGE_CLASS_FLAG_BINARY_DATA | + MAIL_STORAGE_CLASS_FLAG_STUBS, .v = { NULL, diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index 9874152aa5..39b738ff99 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -81,7 +81,9 @@ enum mail_storage_class_flags { MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUID128 = 0x200, /* Storage deletes all files internally - mailbox list's delete_mailbox() shouldn't delete anything itself. */ - MAIL_STORAGE_CLASS_FLAG_NO_LIST_DELETES = 0x400 + MAIL_STORAGE_CLASS_FLAG_NO_LIST_DELETES = 0x400, + /* Storage supports stubs (used for caching purposes). */ + MAIL_STORAGE_CLASS_FLAG_STUBS = 0x800, }; struct mail_binary_cache { diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index 5167a6d87b..6963c50c70 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -1157,6 +1157,14 @@ static bool mailbox_try_undelete(struct mailbox *box) int mailbox_open(struct mailbox *box) { + /* check that the storage supports stubs if require them */ + if (((box->flags & MAILBOX_FLAG_USE_STUBS) != 0) && + ((box->storage->storage_class->class_flags & MAIL_STORAGE_CLASS_FLAG_STUBS) == 0)) { + mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE, + "Mailbox does not support mail stubs"); + return -1; + } + if (mailbox_open_full(box, NULL) < 0) { if (!box->mailbox_deleted) return -1;