Skip to content

Commit

Permalink
lib-storage: require MAIL_STORAGE_CLASS_FLAG_STUBS when caching
Browse files Browse the repository at this point in the history
If we are going to be using the storage for caching, we should check that
the storage actually supports mail stubs.
  • Loading branch information
Josef 'Jeff' Sipek authored and GitLab committed Nov 22, 2016
1 parent 9d92ea3 commit 08e9fd4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/lib-storage/index/dbox-single/sdbox-storage.c
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/lib-storage/mail-storage-private.h
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions src/lib-storage/mail-storage.c
Expand Up @@ -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;
Expand Down

0 comments on commit 08e9fd4

Please sign in to comment.