nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] dist broken in 1.4

2012-02-02 20:32:01
   KH> I guess I was kinda hoping that others would confirm that dist
   KH> was, indeed, broken for the 1.4 release.  From what I can tell
   KH> it was broken a while ago but no one noticed (I guess users
   KH> of the master branch don't use dist), but I just wanted some
   KH> confirmation.  If no one cares I won't bother with a 1.4.1
   KH> release.

It's broken for me in nmh 1.4 (just built) -- I get an error along the
lines of

  send: unable to link /path/to/Mail/inbox/38325 to
  /path/to/Mail/inboxsendKJwMrv: File exists

Thanks for checking!  Yeah, turns out that had been broken for years.
The following patch should fix it.  I am now mulling over whether
to release a 1.4.1 or a 1.5.

--Ken

commit 01943d78230ead5bcc568e8a87d3cdbaac1f5584
Author: Ken Hornstein <kenh(_at_)pobox(_dot_)com>
Date:   Wed Jan 11 14:48:45 2012 -0500

    Fix two errors in the conversion to m_mktemp2():
    
    - There was an off-by-one error that prevented the temporary file
      from being created in the same directory as the message it was being
      linked to.
    - When using "dist", the assumption was that the temporary file would not
      exist when m_scratch was called (it wanted to link() to the name).  This
      was solved by simply unlink()ing the temporary file after it was created.

diff --git a/sbr/m_mktemp.c b/sbr/m_mktemp.c
index aa25636..9f99119 100644
--- a/sbr/m_mktemp.c
+++ b/sbr/m_mktemp.c
@@ -121,7 +121,7 @@ m_mktemp2 (
         /* No directory component */
         return m_mktemp(pfx_in, fd_ret, fp_ret);
     }
-    n = (int)(cp-dir_in-1); /* Length of dir component */
+    n = (int)(cp-dir_in); /* Length of dir component */
     snprintf(buffer, sizeof(buffer), "%.*s%s", n, dir_in, pfx_in);
     return m_mktemp(buffer, fd_ret, fp_ret);
 }
diff --git a/uip/send.c b/uip/send.c
index 39d425f..62bf60a 100644
--- a/uip/send.c
+++ b/uip/send.c
@@ -426,6 +426,7 @@ go_to_it:
            && altmsg) {
        vec[vecp++] = "-dist";
        distfile = getcpy (m_mktemp2 (altmsg, invo_name, NULL, NULL));
+       unlink(distfile);
        if (link (altmsg, distfile) == NOTOK) {
            if (errno != EXDEV
 #ifdef EISREMOTE
diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c
index 7db5c58..c3d93ff 100644
--- a/uip/whatnowsbr.c
+++ b/uip/whatnowsbr.c
@@ -1313,6 +1313,7 @@ sendit (char *sp, char **arg, char *file, int pushed)
            && altmsg) {
        vec[vecp++] = "-dist";
        distfile = getcpy (m_mktemp2(altmsg, invo_name, NULL, NULL));
+       unlink(distfile);
        if (link (altmsg, distfile) == NOTOK)
            adios (distfile, "unable to link %s to", altmsg);
     } else {

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>