dovecot-2.1: maildir: When noticing invalid 'S' in filename, rep...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Nov 15 00:06:06 EET 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/466badb63c0b
changeset: 13694:466badb63c0b
user: Timo Sirainen <tss at iki.fi>
date: Tue Nov 15 00:05:50 2011 +0200
description:
maildir: When noticing invalid 'S' in filename, replace it with the correct one instead of removing it.
diffstat:
src/lib-storage/index/maildir/maildir-mail.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diffs (31 lines):
diff -r a538eec53922 -r 466badb63c0b src/lib-storage/index/maildir/maildir-mail.c
--- a/src/lib-storage/index/maildir/maildir-mail.c Mon Nov 14 23:15:37 2011 +0200
+++ b/src/lib-storage/index/maildir/maildir-mail.c Tue Nov 15 00:05:50 2011 +0200
@@ -617,6 +617,7 @@
const char *wrong_key_p)
{
const char *fname, *newpath, *extra, *info, *dir;
+ struct stat st;
fname = strrchr(path, '/');
i_assert(fname != NULL);
@@ -627,8 +628,17 @@
info = strchr(fname, MAILDIR_INFO_SEP);
if (info == NULL) info = "";
- newpath = t_strdup_printf("%s/%s%s", dir,
- t_strdup_until(fname, extra), info);
+ if (stat(path, &st) < 0) {
+ if (errno == ENOENT)
+ return 0;
+ mail_storage_set_critical(&mbox->storage->storage,
+ "stat(%s) failed: %m", path);
+ return -1;
+ }
+
+ newpath = t_strdup_printf("%s/%s,S=%"PRIuUOFF_T"%s", dir,
+ t_strdup_until(fname, extra),
+ (uoff_t)st.st_size, info);
if (rename(path, newpath) == 0) {
mail_storage_set_critical(mbox->box.storage,
More information about the dovecot-cvs
mailing list