dovecot-1.3: Added mail_storage_purge() for dbox. dbox no longer...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Apr 10 20:16:51 EEST 2009
details: http://hg.dovecot.org/dovecot-1.3/rev/f3cfa467b3b3
changeset: 9061:f3cfa467b3b3
user: Timo Sirainen <tss at iki.fi>
date: Fri Apr 10 13:16:16 2009 -0400
description:
Added mail_storage_purge() for dbox. dbox no longer calls it automatically at logout.
diffstat:
13 files changed, 44 insertions(+), 15 deletions(-)
src/lib-storage/index/cydir/cydir-storage.c | 3 ++-
src/lib-storage/index/dbox/dbox-storage.c | 4 ++--
src/lib-storage/index/dbox/dbox-sync.c | 17 +++++++++++------
src/lib-storage/index/dbox/dbox-sync.h | 2 +-
src/lib-storage/index/maildir/maildir-storage.c | 3 ++-
src/lib-storage/index/mbox/mbox-storage.c | 3 ++-
src/lib-storage/index/raw/raw-storage.c | 3 ++-
src/lib-storage/index/shared/shared-storage.c | 3 ++-
src/lib-storage/mail-storage-private.h | 1 +
src/lib-storage/mail-storage-service.c | 3 +++
src/lib-storage/mail-storage-service.h | 6 +++++-
src/lib-storage/mail-storage.c | 8 ++++++++
src/lib-storage/mail-storage.h | 3 +++
diffs (207 lines):
diff -r cc4b794ac6b9 -r f3cfa467b3b3 src/lib-storage/index/cydir/cydir-storage.c
--- a/src/lib-storage/index/cydir/cydir-storage.c Thu Apr 09 20:26:30 2009 -0400
+++ b/src/lib-storage/index/cydir/cydir-storage.c Fri Apr 10 13:16:16 2009 -0400
@@ -414,7 +414,8 @@ struct mail_storage cydir_storage = {
index_storage_destroy,
NULL,
cydir_mailbox_open,
- cydir_mailbox_create
+ cydir_mailbox_create,
+ NULL
}
};
diff -r cc4b794ac6b9 -r f3cfa467b3b3 src/lib-storage/index/dbox/dbox-storage.c
--- a/src/lib-storage/index/dbox/dbox-storage.c Thu Apr 09 20:26:30 2009 -0400
+++ b/src/lib-storage/index/dbox/dbox-storage.c Fri Apr 10 13:16:16 2009 -0400
@@ -191,7 +191,6 @@ static void dbox_destroy(struct mail_sto
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
}
};
diff -r cc4b794ac6b9 -r f3cfa467b3b3 src/lib-storage/index/dbox/dbox-sync.c
--- a/src/lib-storage/index/dbox/dbox-sync.c Thu Apr 09 20:26:30 2009 -0400
+++ b/src/lib-storage/index/dbox/dbox-sync.c Fri Apr 10 13:16:16 2009 -0400
@@ -350,23 +350,28 @@ dbox_storage_sync_init(struct mailbox *b
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;
+}
diff -r cc4b794ac6b9 -r f3cfa467b3b3 src/lib-storage/index/dbox/dbox-sync.h
--- a/src/lib-storage/index/dbox/dbox-sync.h Thu Apr 09 20:26:30 2009 -0400
+++ b/src/lib-storage/index/dbox/dbox-sync.h Fri Apr 10 13:16:16 2009 -0400
@@ -37,7 +37,7 @@ int dbox_sync_finish(struct dbox_sync_co
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);
diff -r cc4b794ac6b9 -r f3cfa467b3b3 src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c Thu Apr 09 20:26:30 2009 -0400
+++ b/src/lib-storage/index/maildir/maildir-storage.c Fri Apr 10 13:16:16 2009 -0400
@@ -1084,7 +1084,8 @@ struct mail_storage maildir_storage = {
index_storage_destroy,
maildir_autodetect,
maildir_mailbox_open,
- maildir_mailbox_create
+ maildir_mailbox_create,
+ NULL
}
};
diff -r cc4b794ac6b9 -r f3cfa467b3b3 src/lib-storage/index/mbox/mbox-storage.c
--- a/src/lib-storage/index/mbox/mbox-storage.c Thu Apr 09 20:26:30 2009 -0400
+++ b/src/lib-storage/index/mbox/mbox-storage.c Fri Apr 10 13:16:16 2009 -0400
@@ -1006,7 +1006,8 @@ struct mail_storage mbox_storage = {
index_storage_destroy,
mbox_autodetect,
mbox_mailbox_open,
- mbox_mailbox_create
+ mbox_mailbox_create,
+ NULL
}
};
diff -r cc4b794ac6b9 -r f3cfa467b3b3 src/lib-storage/index/raw/raw-storage.c
--- a/src/lib-storage/index/raw/raw-storage.c Thu Apr 09 20:26:30 2009 -0400
+++ b/src/lib-storage/index/raw/raw-storage.c Fri Apr 10 13:16:16 2009 -0400
@@ -266,7 +266,8 @@ struct mail_storage raw_storage = {
index_storage_destroy,
NULL,
raw_mailbox_open,
- raw_mailbox_create
+ raw_mailbox_create,
+ NULL
}
};
diff -r cc4b794ac6b9 -r f3cfa467b3b3 src/lib-storage/index/shared/shared-storage.c
--- a/src/lib-storage/index/shared/shared-storage.c Thu Apr 09 20:26:30 2009 -0400
+++ b/src/lib-storage/index/shared/shared-storage.c Fri Apr 10 13:16:16 2009 -0400
@@ -325,6 +325,7 @@ struct mail_storage shared_storage = {
index_storage_destroy,
NULL,
NULL,
- shared_mailbox_create
+ shared_mailbox_create,
+ NULL
}
};
diff -r cc4b794ac6b9 -r f3cfa467b3b3 src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h Thu Apr 09 20:26:30 2009 -0400
+++ b/src/lib-storage/mail-storage-private.h Fri Apr 10 13:16:16 2009 -0400
@@ -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 {
diff -r cc4b794ac6b9 -r f3cfa467b3b3 src/lib-storage/mail-storage-service.c
--- a/src/lib-storage/mail-storage-service.c Thu Apr 09 20:26:30 2009 -0400
+++ b/src/lib-storage/mail-storage-service.c Fri Apr 10 13:16:16 2009 -0400
@@ -353,6 +353,9 @@ mail_storage_service_init_user(struct ma
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));
diff -r cc4b794ac6b9 -r f3cfa467b3b3 src/lib-storage/mail-storage-service.h
--- a/src/lib-storage/mail-storage-service.h Thu Apr 09 20:26:30 2009 -0400
+++ b/src/lib-storage/mail-storage-service.h Fri Apr 10 13:16:16 2009 -0400
@@ -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;
diff -r cc4b794ac6b9 -r f3cfa467b3b3 src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c Thu Apr 09 20:26:30 2009 -0400
+++ b/src/lib-storage/mail-storage.c Fri Apr 10 13:16:16 2009 -0400
@@ -331,6 +331,14 @@ int mail_storage_mailbox_create(struct m
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)
{
diff -r cc4b794ac6b9 -r f3cfa467b3b3 src/lib-storage/mail-storage.h
--- a/src/lib-storage/mail-storage.h Thu Apr 09 20:26:30 2009 -0400
+++ b/src/lib-storage/mail-storage.h Fri Apr 10 13:16:16 2009 -0400
@@ -271,6 +271,9 @@ void mail_storage_set_callbacks(struct m
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,
More information about the dovecot-cvs
mailing list