]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added mail_storage_purge() for dbox. dbox no longer calls it automatically at logout.
authorTimo Sirainen <tss@iki.fi>
Fri, 10 Apr 2009 17:16:16 +0000 (13:16 -0400)
committerTimo Sirainen <tss@iki.fi>
Fri, 10 Apr 2009 17:16:16 +0000 (13:16 -0400)
--HG--
branch : HEAD

13 files changed:
src/lib-storage/index/cydir/cydir-storage.c
src/lib-storage/index/dbox/dbox-storage.c
src/lib-storage/index/dbox/dbox-sync.c
src/lib-storage/index/dbox/dbox-sync.h
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/index/raw/raw-storage.c
src/lib-storage/index/shared/shared-storage.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage-service.c
src/lib-storage/mail-storage-service.h
src/lib-storage/mail-storage.c
src/lib-storage/mail-storage.h

index 0ebadc7842b38d26d23f700b0ae6f638bc9c2876..70569cf422901e5358268d0ac642f000f06498f4 100644 (file)
@@ -414,7 +414,8 @@ struct mail_storage cydir_storage = {
                index_storage_destroy,
                NULL,
                cydir_mailbox_open,
-               cydir_mailbox_create
+               cydir_mailbox_create,
+               NULL
        }
 };
 
index cb0c6e1b4cc04c26fdef0a0e18be66cd37cf0830..fae404864118d2b5c0f6409d38b7ab5c94511196 100644 (file)
@@ -191,7 +191,6 @@ static void dbox_destroy(struct mail_storage *_storage)
                        return;
        }
 
-       dbox_sync_purge(storage);
        dbox_files_free(storage);
        dbox_map_deinit(&storage->map);
        array_free(&storage->open_files);
@@ -773,7 +772,8 @@ struct mail_storage dbox_storage = {
                dbox_destroy,
                NULL,
                dbox_mailbox_open,
-               dbox_mailbox_create
+               dbox_mailbox_create,
+               dbox_sync_purge
        }
 };
 
index c81cb8d389ebe6f6b53cfd7b825f3b63034b5462..24dbb25f76781bc323474a248cbdcc11be031f61 100644 (file)
@@ -350,23 +350,28 @@ dbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
        return index_mailbox_sync_init(box, flags, ret < 0);
 }
 
-void dbox_sync_purge(struct dbox_storage *storage)
+int dbox_sync_purge(struct mail_storage *_storage)
 {
+       struct dbox_storage *storage = (struct dbox_storage *)_storage;
        const ARRAY_TYPE(seq_range) *ref0_file_ids;
        struct dbox_file *file;
        struct seq_range_iter iter;
        unsigned int i = 0;
        uint32_t file_id;
        bool deleted;
+       int ret = 0;
 
        ref0_file_ids = dbox_map_get_zero_ref_files(storage->map);
        seq_range_array_iter_init(&iter, ref0_file_ids); i = 0;
        while (seq_range_array_iter_nth(&iter, i++, &file_id)) T_BEGIN {
                file = dbox_file_init_multi(storage, file_id);
-               if (dbox_file_open_or_create(file, &deleted) > 0 && !deleted)
-                       (void)dbox_sync_file_purge(file);
-               else
+               if (dbox_file_open_or_create(file, &deleted) > 0 && !deleted) {
+                       if (dbox_sync_file_purge(file) < 0)
+                               ret = -1;
+               } else {
                        dbox_map_remove_file_id(storage->map, file_id);
+               }
                dbox_file_unref(&file);
        } T_END;
+       return ret;
 }
index c90c8134290ededee9b55e015b8a17ae59d980e3..439e1f770a222f695f7924f5f8ffa28c774a8b2f 100644 (file)
@@ -37,7 +37,7 @@ int dbox_sync_begin(struct dbox_mailbox *mbox, enum dbox_sync_flags flags,
 int dbox_sync_finish(struct dbox_sync_context **ctx, bool success);
 int dbox_sync(struct dbox_mailbox *mbox);
 
-void dbox_sync_purge(struct dbox_storage *storage);
+int dbox_sync_purge(struct mail_storage *storage);
 int dbox_sync_file(struct dbox_sync_context *ctx,
                   const struct dbox_sync_file_entry *entry);
 int dbox_sync_file_purge(struct dbox_file *file);
index 35b7094e2f27f84e97e3f34afc7df8b16d72d17e..0f7d63fda03e9961174cb97e5d97f5ab19af23d0 100644 (file)
@@ -1084,7 +1084,8 @@ struct mail_storage maildir_storage = {
                index_storage_destroy,
                maildir_autodetect,
                maildir_mailbox_open,
-               maildir_mailbox_create
+               maildir_mailbox_create,
+               NULL
        }
 };
 
index ece0237fe7429a986ece09c41d7df47d3a0f4d21..d35f0fab20ffd5d21c3eb80926aad8dcd20441fd 100644 (file)
@@ -1006,7 +1006,8 @@ struct mail_storage mbox_storage = {
                index_storage_destroy,
                mbox_autodetect,
                mbox_mailbox_open,
-               mbox_mailbox_create
+               mbox_mailbox_create,
+               NULL
        }
 };
 
index 6cab2f30abe7db4d2c4461320209f7700d064127..43404bc2266005c6e32b2c7ac506e641920ca686 100644 (file)
@@ -266,7 +266,8 @@ struct mail_storage raw_storage = {
                index_storage_destroy,
                NULL,
                raw_mailbox_open,
-               raw_mailbox_create
+               raw_mailbox_create,
+               NULL
        }
 };
 
index fec0a3231526ff287ff0008ab03679dce245a0b2..58dc31f30c6e61d9d6b6cd6fd25c613cd0dca04d 100644 (file)
@@ -325,6 +325,7 @@ struct mail_storage shared_storage = {
                index_storage_destroy,
                NULL,
                NULL,
-               shared_mailbox_create
+               shared_mailbox_create,
+               NULL
        }
 };
index 221934ab35a5e8f5e2de5de85f5ee6b34d238881..adf5bfd3582ab05d3f534a68e31ee6cbdc67acc6 100644 (file)
@@ -42,6 +42,7 @@ struct mail_storage_vfuncs {
 
        int (*mailbox_create)(struct mail_storage *storage, const char *name,
                              bool directory);
+       int (*purge)(struct mail_storage *storage);
 };
 
 union mail_storage_module_context {
index 7ce54b6ab4f1b7ba0cfa6cc5f6c2b7c18e6dbf5a..2d79244a245851c93fbcee617ce15b0581629469 100644 (file)
@@ -353,6 +353,9 @@ mail_storage_service_init_user(struct master_service *service, const char *user,
        userdb_lookup = (flags & MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP) != 0;
        mail_storage_service_init_settings(service, set_root, !userdb_lookup);
 
+       if ((flags & MAIL_STORAGE_SERVICE_FLAG_DEBUG) != 0)
+               master_service_set(service, "mail_debug", "yes");
+
        /* now that we've read settings, we can set up logging */
        master_service_init_log(service,
                t_strdup_printf("%s(%s): ", service->name, user));
index 2e6a03563103e948edf29c269b74eaf0d17e576a..2e9077335c39086fdd795f72ce57b8ccdae56ab0 100644 (file)
@@ -2,8 +2,12 @@
 #define MAIL_STORAGE_SERVICE_H
 
 enum mail_storage_service_flags {
+       /* Fail if we don't drop root privileges */
        MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT         = 0x01,
-       MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP         = 0x02
+       /* Lookup user from userdb */
+       MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP         = 0x02,
+       /* Force mail_debug=yes */
+       MAIL_STORAGE_SERVICE_FLAG_DEBUG                 = 0x04
 };
 
 struct setting_parser_info;
index 588cb3869302e60e968a96be33e4b7585b11f12f..866f405c32e63d13ed4f3e0626ec1081d7cdb48f 100644 (file)
@@ -331,6 +331,14 @@ int mail_storage_mailbox_create(struct mail_storage *storage, const char *name,
        return storage->v.mailbox_create(storage, name, directory);
 }
 
+int mail_storage_purge(struct mail_storage *storage)
+{
+       mail_storage_clear_error(storage);
+
+       return storage->v.purge == NULL ? 0 :
+               storage->v.purge(storage);
+}
+
 const char *mail_storage_get_last_error(struct mail_storage *storage,
                                        enum mail_error *error_r)
 {
index b0e79039505d8e47cb68d1d55e25b21ad97ae2cf..af1b82b929dbf48f77b1b5505870f125d2f0aaf3 100644 (file)
@@ -271,6 +271,9 @@ void mail_storage_set_callbacks(struct mail_storage *storage,
    created as long as it shows in LIST. */
 int mail_storage_mailbox_create(struct mail_storage *storage, const char *name,
                                bool directory);
+/* Purge storage's mailboxes (freeing disk space from expunged mails),
+   if supported by the storage. Otherwise just a no-op. */
+int mail_storage_purge(struct mail_storage *storage);
 
 /* Returns the error message of last occurred error. */
 const char *mail_storage_get_last_error(struct mail_storage *storage,