dovecot-2.2: maildir: If filename begins with ':', rename it imm...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Nov 2 13:34:28 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/58dfed53ab43
changeset: 16908:58dfed53ab43
user: Timo Sirainen <tss at iki.fi>
date: Sat Nov 02 13:34:17 2013 +0200
description:
maildir: If filename begins with ':', rename it immediately instead of causing errors.
diffstat:
src/lib-storage/index/maildir/maildir-sync.c | 29 ++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diffs (46 lines):
diff -r d3062d066593 -r 58dfed53ab43 src/lib-storage/index/maildir/maildir-sync.c
--- a/src/lib-storage/index/maildir/maildir-sync.c Sat Nov 02 13:14:16 2013 +0200
+++ b/src/lib-storage/index/maildir/maildir-sync.c Sat Nov 02 13:34:17 2013 +0200
@@ -362,6 +362,27 @@
}
static int
+maildir_rename_empty_basename(struct maildir_sync_context *ctx,
+ const char *dir, const char *fname)
+{
+ const char *old_path, *new_fname, *new_path;
+
+ old_path = t_strconcat(dir, "/", fname, NULL);
+ new_fname = maildir_filename_generate();
+ new_path = t_strconcat(mailbox_get_path(&ctx->mbox->box),
+ "/new/", new_fname, NULL);
+ if (rename(old_path, new_path) == 0)
+ i_warning("Fixed broken filename: %s -> %s", old_path, new_fname);
+ else if (errno != ENOENT) {
+ mail_storage_set_critical(&ctx->mbox->storage->storage,
+ "Couldn't fix a broken filename: rename(%s, %s) failed: %m",
+ old_path, new_path);
+ return -1;
+ }
+ return 0;
+}
+
+static int
maildir_stat(struct maildir_mailbox *mbox, const char *path, struct stat *st_r)
{
struct mailbox *box = &mbox->box;
@@ -457,6 +478,14 @@
if (dp->d_name[0] == '.')
continue;
+ if (dp->d_name[0] == MAILDIR_INFO_SEP) {
+ /* don't even try to use file with empty base name */
+ if (maildir_rename_empty_basename(ctx, path,
+ dp->d_name) < 0)
+ break;
+ continue;
+ }
+
flags = 0;
if (move_new) {
i_assert(dp->d_name[0] != '\0');
More information about the dovecot-cvs
mailing list