]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added MAIL_STORAGE_CLASS_FLAG_NO_LIST_DELETES and MAILBOX_LIST_FLAG_NO_D...
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 19 Apr 2016 13:59:48 +0000 (16:59 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 19 Apr 2016 13:59:48 +0000 (16:59 +0300)
src/lib-storage/list/mailbox-list-index-backend.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c
src/lib-storage/mailbox-list.h

index da40d0aa3c45c61e2c42c00efb7cdbe606fc2c5b..4cef1bcf69377a21db3e8e0c47d4f24d43395305 100644 (file)
@@ -526,7 +526,8 @@ index_list_delete_mailbox(struct mailbox_list *_list, const char *name)
        if (ret <= 0)
                return ret;
 
-       if ((_list->flags & MAILBOX_LIST_FLAG_NO_MAIL_FILES) != 0) {
+       if ((_list->flags & (MAILBOX_LIST_FLAG_NO_MAIL_FILES |
+                            MAILBOX_LIST_FLAG_NO_DELETES)) != 0) {
                ret = 0;
        } else if ((_list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) != 0) {
                ret = mailbox_list_delete_mailbox_file(_list, name, path);
@@ -535,7 +536,8 @@ index_list_delete_mailbox(struct mailbox_list *_list, const char *name)
                                                               path, TRUE);
        }
 
-       if (ret == 0 || (_list->props & MAILBOX_LIST_PROP_AUTOCREATE_DIRS) != 0)
+       if ((ret == 0 || (_list->props & MAILBOX_LIST_PROP_AUTOCREATE_DIRS) != 0) &&
+           (_list->flags & MAILBOX_LIST_FLAG_NO_DELETES) == 0)
                index_list_delete_finish(_list, name);
        if (ret == 0) {
                if (index_list_delete_entry(list, name, TRUE) < 0)
index d1f1a8250c80789e405ef472899f6e2a1387db89..6a2b53756e555c6e9cd94f832cbd481da176e5df 100644 (file)
@@ -78,7 +78,10 @@ enum mail_storage_class_flags {
        MAIL_STORAGE_CLASS_FLAG_BINARY_DATA     = 0x100,
        /* Message GUIDs can only be 128bit (always set
           mailbox_status.have_only_guid128) */
-       MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUID128 = 0x200
+       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
 };
 
 struct mail_binary_cache {
index 331b867d82fbcfb29893910ecdc2a98397a62864..454df24a9bcbabe686e73ce1f5f4f7d084cbf871 100644 (file)
@@ -360,6 +360,8 @@ int mail_storage_create_full(struct mail_namespace *ns, const char *driver,
                        list_flags |= MAILBOX_LIST_FLAG_MAILBOX_FILES;
                if ((storage_class->class_flags & MAIL_STORAGE_CLASS_FLAG_NO_ROOT) != 0)
                        list_flags |= MAILBOX_LIST_FLAG_NO_MAIL_FILES;
+               if ((storage_class->class_flags & MAIL_STORAGE_CLASS_FLAG_NO_LIST_DELETES) != 0)
+                       list_flags |= MAILBOX_LIST_FLAG_NO_DELETES;
                if (mailbox_list_create(list_set.layout, ns, &list_set,
                                        list_flags, &list, error_r) < 0) {
                        *error_r = t_strdup_printf("Mailbox list driver %s: %s",
index 8f5998c3ebeb169a23839ebd4859b7fc18da9518..ae953837bcb3cd5068528dc891fd6cea05dea2db 100644 (file)
@@ -34,7 +34,9 @@ enum mailbox_list_flags {
           mailbox list to it. */
        MAILBOX_LIST_FLAG_SECONDARY             = 0x02,
        /* There are no mail files, only index and/or control files. */
-       MAILBOX_LIST_FLAG_NO_MAIL_FILES         = 0x04
+       MAILBOX_LIST_FLAG_NO_MAIL_FILES         = 0x04,
+       /* LAYOUT=index: Don't delete any files in delete_mailbox(). */
+       MAILBOX_LIST_FLAG_NO_DELETES            = 0x08
 };
 
 enum mailbox_info_flags {