From: Timo Sirainen Date: Thu, 21 Oct 2010 17:49:19 +0000 (+0100) Subject: dbox: Reverted the "check if altpath is mounted" change for now. X-Git-Tag: 2.0.6~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ca83616715c3bd417e34ced2c1d61852513e427;p=thirdparty%2Fdovecot%2Fcore.git dbox: Reverted the "check if altpath is mounted" change for now. If alt path didn't yet exist, it reported bogus errors. It should somehow check if there is anything under the alt root dir. --- diff --git a/src/lib-storage/index/dbox-multi/mdbox-file.c b/src/lib-storage/index/dbox-multi/mdbox-file.c index a13b39f53c..745c8672c3 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-file.c +++ b/src/lib-storage/index/dbox-multi/mdbox-file.c @@ -183,32 +183,6 @@ mdbox_file_init_new_alt(struct mdbox_storage *storage) return mdbox_file_init_full(storage, 0, TRUE); } -int mdbox_file_open(struct dbox_file *file, bool *deleted_r) -{ - struct mdbox_file *mfile = (struct mdbox_file *)file; - struct stat st; - int ret; - - if ((ret = dbox_file_open(file, deleted_r)) <= 0 || !*deleted_r) - return ret; - - /* file appears to be deleted. check if the alt path root even exists - to avoid reindexing errors if alt path isn't mounted currently */ - if (stat(mfile->storage->alt_storage_dir, &st) == 0) - return 1; - else if (errno == ENOENT) { - mail_storage_set_critical(&file->storage->storage, - "mdbox: User's alt path lost: %s", - mfile->storage->alt_storage_dir); - return -1; - } else { - mail_storage_set_critical(&file->storage->storage, - "stat(%s) failed: %m", mfile->storage->alt_storage_dir); - return -1; - } -} - - int mdbox_file_assign_file_id(struct mdbox_file *file, uint32_t file_id) { const char *old_path; diff --git a/src/lib-storage/index/dbox-multi/mdbox-file.h b/src/lib-storage/index/dbox-multi/mdbox-file.h index 7750de59c3..9095cce745 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-file.h +++ b/src/lib-storage/index/dbox-multi/mdbox-file.h @@ -16,8 +16,6 @@ mdbox_file_init(struct mdbox_storage *storage, uint32_t file_id); struct dbox_file * mdbox_file_init_new_alt(struct mdbox_storage *storage); -int mdbox_file_open(struct dbox_file *file, bool *deleted_r); - /* Assign file ID for a newly created file. */ int mdbox_file_assign_file_id(struct mdbox_file *file, uint32_t file_id); diff --git a/src/lib-storage/index/dbox-multi/mdbox-mail.c b/src/lib-storage/index/dbox-multi/mdbox-mail.c index c67843bf7f..da776836c6 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-mail.c +++ b/src/lib-storage/index/dbox-multi/mdbox-mail.c @@ -129,7 +129,7 @@ int mdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r, if (!dbox_file_is_open(mail->open_file)) mail->imail.mail.stats_open_lookup_count++; - if (mdbox_file_open(mail->open_file, &deleted) <= 0) + if (dbox_file_open(mail->open_file, &deleted) <= 0) return -1; if (deleted) { /* either it's expunged now or moved to another file. */ diff --git a/src/lib-storage/index/dbox-multi/mdbox-purge.c b/src/lib-storage/index/dbox-multi/mdbox-purge.c index 8e5442c729..33405d3684 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-purge.c +++ b/src/lib-storage/index/dbox-multi/mdbox-purge.c @@ -658,7 +658,7 @@ int mdbox_purge(struct mail_storage *_storage) while (ret == 0 && seq_range_array_iter_nth(&iter, i++, &file_id)) T_BEGIN { file = mdbox_file_init(storage, file_id); - if (mdbox_file_open(file, &deleted) > 0 && !deleted) { + if (dbox_file_open(file, &deleted) > 0 && !deleted) { if (mdbox_file_purge(ctx, file) < 0) ret = -1; } else { diff --git a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c index e9541a4bd6..68c2efe0e3 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c @@ -277,7 +277,7 @@ static int rebuild_add_file(struct mdbox_storage_rebuild_context *ctx, seq_range_array_add(&ctx->seen_file_ids, 0, file_id); file = mdbox_file_init(ctx->storage, file_id); - if ((ret = mdbox_file_open(file, &deleted)) > 0 && !deleted) + if ((ret = dbox_file_open(file, &deleted)) > 0 && !deleted) ret = rebuild_file_mails(ctx, file, file_id); if (ret == 0) i_error("mdbox rebuild: Failed to fix file %s/%s", dir, fname); @@ -614,7 +614,7 @@ static int rebuild_restore_msg(struct mdbox_storage_rebuild_context *ctx, /* first see if message contains the mailbox it was originally saved to */ file = mdbox_file_init(ctx->storage, msg->file_id); - ret = mdbox_file_open(file, &deleted); + ret = dbox_file_open(file, &deleted); if (ret > 0 && !deleted) ret = dbox_file_seek(file, msg->offset); if (ret > 0 && !deleted && dbox_file_metadata_read(file) > 0) { diff --git a/src/lib-storage/index/dbox-single/sdbox-file.c b/src/lib-storage/index/dbox-single/sdbox-file.c index 6df975d7a6..be15a67ce0 100644 --- a/src/lib-storage/index/dbox-single/sdbox-file.c +++ b/src/lib-storage/index/dbox-single/sdbox-file.c @@ -73,33 +73,6 @@ void sdbox_file_free(struct dbox_file *file) dbox_file_free(file); } -int sdbox_file_open(struct dbox_file *file, bool *deleted_r) -{ - struct sdbox_file *sfile = (struct sdbox_file *)file; - struct stat st; - const char *alt_root; - int ret; - - if ((ret = dbox_file_open(file, deleted_r)) <= 0 || !*deleted_r) - return ret; - - /* file appears to be deleted. check if the alt path root even exists - to avoid reindexing errors if alt path isn't mounted currently */ - alt_root = mailbox_list_get_path(sfile->mbox->box.list, NULL, - MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX); - if (stat(alt_root, &st) == 0) - return 1; - else if (errno == ENOENT) { - mail_storage_set_critical(&file->storage->storage, - "sdbox: User's alt path lost: %s", alt_root); - return -1; - } else { - mail_storage_set_critical(&file->storage->storage, - "stat(%s) failed: %m", alt_root); - return -1; - } -} - int sdbox_file_get_attachments(struct dbox_file *file, const char **extrefs_r) { const char *line; @@ -109,7 +82,7 @@ int sdbox_file_get_attachments(struct dbox_file *file, const char **extrefs_r) *extrefs_r = NULL; /* read the metadata */ - ret = sdbox_file_open(file, &deleted); + ret = dbox_file_open(file, &deleted); if (ret > 0) { if (deleted) return 0; @@ -392,7 +365,7 @@ int sdbox_file_move(struct dbox_file *file, bool alt_path) /* file was successfully moved - reopen it */ dbox_file_close(file); - if (sdbox_file_open(file, &deleted) <= 0) { + if (dbox_file_open(file, &deleted) <= 0) { mail_storage_set_critical(storage, "dbox_file_move(%s): reopening file failed", dest_path); return -1; diff --git a/src/lib-storage/index/dbox-single/sdbox-file.h b/src/lib-storage/index/dbox-single/sdbox-file.h index 4a707cf9ba..30eb4f4878 100644 --- a/src/lib-storage/index/dbox-single/sdbox-file.h +++ b/src/lib-storage/index/dbox-single/sdbox-file.h @@ -19,8 +19,6 @@ struct dbox_file *sdbox_file_init(struct sdbox_mailbox *mbox, uint32_t uid); struct dbox_file *sdbox_file_create(struct sdbox_mailbox *mbox); void sdbox_file_free(struct dbox_file *file); -int sdbox_file_open(struct dbox_file *file, bool *deleted_r); - /* Get file's extrefs metadata. */ int sdbox_file_get_attachments(struct dbox_file *file, const char **extrefs_r); /* Returns attachment path for this file, given the source path. The result is diff --git a/src/lib-storage/index/dbox-single/sdbox-mail.c b/src/lib-storage/index/dbox-single/sdbox-mail.c index 1c34d6a4e3..0b573d910d 100644 --- a/src/lib-storage/index/dbox-single/sdbox-mail.c +++ b/src/lib-storage/index/dbox-single/sdbox-mail.c @@ -43,7 +43,7 @@ static bool sdbox_mail_file_set(struct dbox_mail *mail) mail->open_file->refcount++; /* it doesn't have input stream yet */ - ret = sdbox_file_open(mail->open_file, &deleted); + ret = dbox_file_open(mail->open_file, &deleted); i_assert(ret > 0); return TRUE; } @@ -63,7 +63,7 @@ int sdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r, if (!sdbox_mail_file_set(mail)) { if (!dbox_file_is_open(mail->open_file)) mail->imail.mail.stats_open_lookup_count++; - if (sdbox_file_open(mail->open_file, &deleted) <= 0) + if (dbox_file_open(mail->open_file, &deleted) <= 0) return -1; if (deleted) { sdbox_mail_set_expunged(mail); diff --git a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c index eb7bbcbcd6..b2f2e86f13 100644 --- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c +++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c @@ -32,7 +32,7 @@ static int sdbox_sync_add_file_index(struct dbox_sync_rebuild_context *ctx, bool deleted; int ret; - if ((ret = sdbox_file_open(file, &deleted)) > 0) { + if ((ret = dbox_file_open(file, &deleted)) > 0) { if (deleted) return 0; ret = dbox_file_seek(file, 0); diff --git a/src/lib-storage/index/dbox-single/sdbox-sync.c b/src/lib-storage/index/dbox-single/sdbox-sync.c index b31518a89c..c3beab76c2 100644 --- a/src/lib-storage/index/dbox-single/sdbox-sync.c +++ b/src/lib-storage/index/dbox-single/sdbox-sync.c @@ -18,7 +18,7 @@ dbox_sync_file_move_if_needed(struct dbox_file *file, if (move_to_alt != dbox_file_is_in_alt(file)) { /* move the file. if it fails, nothing broke so don't worry about it. */ - if (sdbox_file_open(file, &deleted) > 0 && !deleted) + if (dbox_file_open(file, &deleted) > 0 && !deleted) (void)sdbox_file_move(file, move_to_alt); } }