From: Ken Hornstein Date: Sun, 24 Mar 2013 02:59:24 +0000 (-0400) Subject: Change folder_delmsgs() to save context and sequence files (and make X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/21684f3b83eb0b29e6ead6f60955826de379541a?ds=inline Change folder_delmsgs() to save context and sequence files (and make sure those changes are before calling rmmproc(). Update programs that use folder_delmsgs() to make all changes to sequences and the context before calling folder_delmsgs(). --- diff --git a/sbr/folder_delmsgs.c b/sbr/folder_delmsgs.c index 7431b62e..ee4bd9e9 100644 --- a/sbr/folder_delmsgs.c +++ b/sbr/folder_delmsgs.c @@ -40,6 +40,14 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) /* Mark that the sequence information has changed */ mp->msgflags |= SEQMOD; + /* + * Write out the sequence and context files; this will release + * any locks before the rmmproc is called. + */ + + seq_save (mp); + context_save (); + vec = argsplit(rmmproc, &prog, &vecp); /* @@ -132,5 +140,12 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) /* Mark that the sequence information has changed */ mp->msgflags |= SEQMOD; + /* + * Write out sequence and context files + */ + + seq_save (mp); + context_save (); + return retval; } diff --git a/uip/refile.c b/uip/refile.c index 725a7ada..8a4392b7 100644 --- a/uip/refile.c +++ b/uip/refile.c @@ -239,16 +239,19 @@ main (int argc, char **argv) } /* - * This is a hack. If we are using an external rmmproc, - * then save the current folder to the context file, - * so the external rmmproc will remove files from the correct - * directory. This should be moved to folder_delmsgs(). + * Update this now, since folder_delmsgs() will save the context + * but doesn't have access to the folder name. */ - if (rmmproc) { - context_replace (pfolder, folder); - context_save (); - fflush (stdout); - } + + context_replace (pfolder, folder); /* update current folder */ + + /* + * Adjust "cur" if necessary + */ + + if (mp->hghsel != mp->curmsg + && (mp->numsel != mp->nummsg || linkf)) + seq_setcur (mp, mp->hghsel); /* If -nolink, then "remove" messages from source folder. * @@ -257,17 +260,13 @@ main (int argc, char **argv) */ if (!linkf) { folder_delmsgs (mp, unlink_msgs, 1); + } else { + seq_save (mp); /* synchronize message sequences */ + context_save (); /* save the context file */ } clsfolds (folders, foldp); - if (mp->hghsel != mp->curmsg - && (mp->numsel != mp->nummsg || linkf)) - seq_setcur (mp, mp->hghsel); - seq_save (mp); /* synchronize message sequences */ - - context_replace (pfolder, folder); /* update current folder */ - context_save (); /* save the context file */ folder_free (mp); /* free folder structure */ done (0); return 1; diff --git a/uip/rmm.c b/uip/rmm.c index 64d85cea..ee602b45 100644 --- a/uip/rmm.c +++ b/uip/rmm.c @@ -118,24 +118,16 @@ main (int argc, char **argv) seq_setprev (mp); /* set the previous-sequence */ /* - * This is hackish. If we are using a external rmmproc, - * then we need to update the current folder in the - * context so the external rmmproc will remove files - * from the correct directory. This should be moved to - * folder_delmsgs(). + * As part of the new world locking order, folder_delmsgs() now updates + * the sequence and context for us. But since folder_delmsgs() doesn't + * have access to the folder name, change the context now. */ - if (rmmproc) { - context_replace (pfolder, folder); - context_save (); - fflush (stdout); - } + + context_replace (pfolder, folder); /* "remove" the SELECTED messages */ folder_delmsgs (mp, unlink_msgs, 0); - seq_save (mp); /* synchronize message sequences */ - context_replace (pfolder, folder); /* update current folder */ - context_save (); /* save the context file */ folder_free (mp); /* free folder structure */ done (0); return 1;