]> diplodocus.org Git - minc/commitdiff
Fix bug with compacting the messages that stay in inbox. lock
authorEric Gillespie <epg@pretzelnet.org>
Wed, 10 Dec 2014 08:59:32 +0000 (00:59 -0800)
committerEric Gillespie <epg@pretzelnet.org>
Wed, 10 Dec 2014 08:59:32 +0000 (00:59 -0800)
Rename store_message variables so this actually makes sense.

minc

diff --git a/minc b/minc
index 22ef14397ff52ca7e7177c47405e7ad9d0662b48..c0688d691865534c54097eab7e00d3417eb14c33 100755 (executable)
--- a/minc
+++ b/minc
@@ -422,9 +422,9 @@ sub lkopen_fcntl {
 my @filtered;
 sub store_message {
     my $inbox = shift;
-    my $msg = shift;            # rename $src_msg
+    my $src_msgpath = shift;
     my $mhfolder = shift;
-    my ($msgnum, $mhmsg);       # rename $dst_msg and $dst_msgpath
+    my ($dst_msgnum, $dst_msgpath);
 
     # We must do this even in -n mode because later steps fail without
     # it.  This should be harmless.
@@ -432,20 +432,21 @@ sub store_message {
 
     if ("+$mhfolder" eq $inbox) {
         # If @filtered is empty, this message already has the right number.
-        if (!($msgnum = shift(@filtered))) {
-            $msg =~ m|.*/(\d+)$|;
+        if (!($dst_msgpath = shift(@filtered))) {
+            $src_msgpath =~ m|.*/(\d+)$|;
             return $1;
         }
-        $mhmsg = "$mh/$mhfolder/$msgnum";
+        $dst_msgpath =~ m|.*/(\d+)$|;
+        $dst_msgnum = $1;
     } else {
         # This loop is a modified version of the maildir delivery algorithm.
-        $msgnum = get_highest_msgnum($mhfolder);
+        $dst_msgnum = get_highest_msgnum($mhfolder);
         my $try;
         for ($try = 0; ; $try++) {
-            $msgnum++;
-            $mhmsg = "$mh/$mhfolder/$msgnum";
+            $dst_msgnum++;
+            $dst_msgpath = "$mh/$mhfolder/$dst_msgnum";
 
-            if (not stat($mhmsg)) {
+            if (not stat($dst_msgpath)) {
                 if ($!{ENOENT}) {
                     # Now we have a non-existent file, let's try to create
                     # it.  We must create a zero-byte file first because a
@@ -466,7 +467,7 @@ sub store_message {
                     # file is left behind as opposed to a duplicate
                     # message.  This is more easily detected by the user.
                     if ($run) {
-                        if (sysopen(MSG, $mhmsg,
+                        if (sysopen(MSG, $dst_msgpath,
                                     O_WRONLY | O_EXCL | O_CREAT, 0600)) {
                             close(MSG);
                             last;
@@ -480,7 +481,7 @@ sub store_message {
             # This algorithm is different from the maildir one; let's make
             # 10 tries instead of 3.
             if ($try == 9) {
-                die("Attempted filename $mhmsg exists.");
+                die("Attempted filename $dst_msgpath exists.");
             }
 
             # This algorithm is different; i don't think we need to sleep.
@@ -493,19 +494,19 @@ sub store_message {
             # messages and then have a failure before marking some (or
             # all).
             if ($mhfolder ne 'SPAM') {
-                mark($mhfolder, $msgnum, 'unseen');
+                mark($mhfolder, $dst_msgnum, 'unseen');
             }
         }
     }
-    push(@filtered, $msg);
+    push(@filtered, $src_msgpath);
 
     if ($run) {
-        if (not rename($msg, $mhmsg)) {
-            die("rename($msg, $mhmsg): $!");
+        if (not rename($src_msgpath, $dst_msgpath)) {
+            die("rename($src_msgpath, $dst_msgpath): $!");
         }
     }
 
-    return $msgnum;
+    return $dst_msgnum;
 }
 
 # Parse a message file into a structure describing the headers.  The