- create_folder (nmaildir, 0, done);
-
- if (chdir (nmaildir) == NOTOK)
- adios (nmaildir, "unable to change directory to");
- if (!(mp = folder_read (fp->f_name, 1)))
- adios (NULL, "unable to read folder %s", fp->f_name);
- mp->curmsg = 0;
-
- fp->f_mp = mp;
+ /*
+ * Null src_folder indicates that we are refiling a file to
+ * the folders, in which case we don't want to short-circuit
+ * fp->f_mp to any "source folder".
+ */
+ if (! src_folder || strcmp (src_folder->foldpath, nmaildir)) {
+ create_folder (nmaildir, 0, done);
+
+ if (chdir (nmaildir) == NOTOK)
+ adios (nmaildir, "unable to change directory to");
+ if (!(mp = folder_read (fp->f_name, 1)))
+ adios (NULL, "unable to read folder %s", fp->f_name);
+ mp->curmsg = 0;
+
+ fp->f_mp = mp;
+ } else {
+ /* Source and destination folders are the same. */
+ fp->f_mp = src_folder;
+ }