dovecot-2.1: maildir: Log less lines when removing broken sizes ...

dovecot at dovecot.org dovecot at dovecot.org
Tue Nov 8 22:28:14 EET 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/762b31157c42
changeset: 13673:762b31157c42
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Nov 08 22:38:36 2011 +0200
description:
maildir: Log less lines when removing broken sizes from filenames.

diffstat:

 src/lib-storage/index/maildir/maildir-mail.c |  33 ++++++++++++++++-----------
 1 files changed, 19 insertions(+), 14 deletions(-)

diffs (57 lines):

diff -r 96e469ea4fc8 -r 762b31157c42 src/lib-storage/index/maildir/maildir-mail.c
--- a/src/lib-storage/index/maildir/maildir-mail.c	Tue Nov 08 21:50:46 2011 +0200
+++ b/src/lib-storage/index/maildir/maildir-mail.c	Tue Nov 08 22:38:36 2011 +0200
@@ -620,6 +620,7 @@
 	enum maildir_uidlist_rec_flag flags;
 	const char *subdir, *fname, *path, *newpath, *p;
 	uoff_t size;
+	char wrong_key;
 
 	if (maildir_sync_lookup(mbox, mail->uid, &flags, &fname) <= 0)
 		return;
@@ -633,27 +634,31 @@
 	path = t_strdup_printf("%s/%s/%s", mailbox_get_path(&mbox->box),
 			       subdir, fname);
 
-	if (maildir_filename_get_size(fname, MAILDIR_EXTRA_VIRTUAL_SIZE,
-				      &size) &&
-	    field == MAIL_FETCH_VIRTUAL_SIZE) {
-		mail_storage_set_critical(mail->box->storage,
-			"Maildir filename has wrong W value: %s", path);
-	}
-	if (maildir_filename_get_size(fname, MAILDIR_EXTRA_FILE_SIZE,
-				      &size) &&
-	    field == MAIL_FETCH_PHYSICAL_SIZE) {
-		mail_storage_set_critical(mail->box->storage,
-			"Maildir filename has wrong S value: %s", path);
+	if (field == MAIL_FETCH_VIRTUAL_SIZE &&
+	    maildir_filename_get_size(fname, MAILDIR_EXTRA_VIRTUAL_SIZE,
+				      &size)) {
+		wrong_key = 'W';
+	} else if (field == MAIL_FETCH_PHYSICAL_SIZE &&
+		   maildir_filename_get_size(fname, MAILDIR_EXTRA_FILE_SIZE,
+					     &size)) {
+		wrong_key = 'S';
+	} else {
+		/* the broken size isn't in filename */
+		return;
 	}
 
 	newpath = t_strdup_printf("%s/%s/%s", mailbox_get_path(&mbox->box),
 				  subdir, t_strdup_until(fname, p));
 	if (rename(path, newpath) == 0) {
-		i_warning("Renamed broken maildir filename %s to %s",
-			  path, newpath);
+		mail_storage_set_critical(mail->box->storage,
+			"Maildir filename has wrong %c value, "
+			"renamed the file from %s to %s",
+			wrong_key, path, newpath);
 	} else {
 		mail_storage_set_critical(mail->box->storage,
-			"rename(%s, %s) failed: %m", path, newpath);
+			"Maildir filename has wrong %c value, "
+			"but rename(%s, %s) failed: %m",
+			wrong_key, path, newpath);
 	}
 }
 


More information about the dovecot-cvs mailing list