index_storage_destroy,
NULL,
cydir_mailbox_open,
- cydir_mailbox_create
+ cydir_mailbox_create,
+ NULL
}
};
return;
}
- dbox_sync_purge(storage);
dbox_files_free(storage);
dbox_map_deinit(&storage->map);
array_free(&storage->open_files);
dbox_destroy,
NULL,
dbox_mailbox_open,
- dbox_mailbox_create
+ dbox_mailbox_create,
+ dbox_sync_purge
}
};
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;
}
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_storage_destroy,
maildir_autodetect,
maildir_mailbox_open,
- maildir_mailbox_create
+ maildir_mailbox_create,
+ NULL
}
};
index_storage_destroy,
mbox_autodetect,
mbox_mailbox_open,
- mbox_mailbox_create
+ mbox_mailbox_create,
+ NULL
}
};
index_storage_destroy,
NULL,
raw_mailbox_open,
- raw_mailbox_create
+ raw_mailbox_create,
+ NULL
}
};
index_storage_destroy,
NULL,
NULL,
- shared_mailbox_create
+ shared_mailbox_create,
+ NULL
}
};
int (*mailbox_create)(struct mail_storage *storage, const char *name,
bool directory);
+ int (*purge)(struct mail_storage *storage);
};
union mail_storage_module_context {
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));
#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;
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)
{
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,