]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
maildir: When noticing invalid 'S' in filename, replace it with the correct one inste...
authorTimo Sirainen <tss@iki.fi>
Mon, 14 Nov 2011 22:05:50 +0000 (00:05 +0200)
committerTimo Sirainen <tss@iki.fi>
Mon, 14 Nov 2011 22:05:50 +0000 (00:05 +0200)
src/lib-storage/index/maildir/maildir-mail.c

index dfbe90796f211c4b00dbce6a93a051c7bdcb1c64..c187c8ce4b772be2cd292d19f74d32ef0fe91443 100644 (file)
@@ -617,6 +617,7 @@ do_fix_size(struct maildir_mailbox *mbox, const char *path,
            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 @@ do_fix_size(struct maildir_mailbox *mbox, const char *path,
        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,