<<< Date Index >>>     <<< Thread Index >>>

Bug#294132: mutt: maildir mtime patch is inefficient



----- Forwarded message from Daniel Jacobowitz <dan@xxxxxxxxxx> -----

Subject: Bug#294132: mutt: maildir mtime patch is inefficient
Reply-To: Daniel Jacobowitz <dan@xxxxxxxxxx>, 294132@xxxxxxxxxxxxxxx
X-Debian-PR-Message: report 294132
X-Debian-PR-Package: mutt
X-Debian-PR-Keywords: patch
From: Daniel Jacobowitz <dan@xxxxxxxxxx>
To: Debian Bug Tracking System <submit@xxxxxxxxxxxxxxx>

Package: mutt
Version: 1.5.6-20040907+3
Severity: normal
Tags: patch

I was merging my local mutt patches today and encountered a conflict on the
maildir-mtime patch.  Here's a much simpler, and superior, solution, which I
posted to mutt-dev a couple of years ago.  Any conforming Maildir client
will always modify the time of dir/tmp/ whenever it makes a change,
including saving messages to the directory; these should affect the
maildir's "modification time".

I deliberately only check the time of things we are treating as mailboxes.
And there's only ever one extra stat.

Index: mutt/browser.c
===================================================================
--- mutt.orig/browser.c 2005-02-03 12:01:42.000000000 -0500
+++ mutt/browser.c      2005-02-07 12:20:29.588523124 -0500
@@ -31,6 +31,7 @@
 #ifdef USE_IMAP
 #include "imap.h"
 #endif
+#include "mx.h"
 
 #include <stdlib.h>
 #include <dirent.h>
@@ -350,6 +351,21 @@ static void init_state (struct browser_s
     menu->data = state->entry;
 }
 
+static void check_maildir_times (BUFFY *buf, struct stat *st)
+{
+  char buffer[_POSIX_PATH_MAX + SHORT_STRING];
+  struct stat s;
+
+  if(!buf || buf->magic != M_MAILDIR)
+    return;
+
+  snprintf (buffer, sizeof (buffer), "%s/tmp", buf->path);
+  if (lstat (buffer, &s) != 0)
+    return;
+
+  st->st_mtime = s.st_mtime;
+}
+
 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
                              char *d, const char *prefix)
 {
@@ -413,6 +429,7 @@ static int examine_directory (MUTTMENU *
     tmp = Incoming;
     while (tmp && mutt_strcmp (buffer, tmp->path))
       tmp = tmp->next;
+    check_maildir_times (tmp, &s);
     add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
   }
   closedir (dp);  
@@ -458,6 +475,7 @@ static int examine_mailboxes (MUTTMENU *
     strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
     mutt_pretty_mailbox (buffer);
 
+    check_maildir_times (tmp, &s);
     add_folder (menu, state, buffer, &s, tmp->new);
   }
   while ((tmp = tmp->next));


-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.10-rc1
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)

Versions of packages mutt depends on:
ii  exim4-daemon-heavy [mail-tr 4.44-2       exim MTA (v4) daemon with extended
ii  libc6                       2.3.2.ds1-20 GNU C Library: Shared libraries an
ii  libidn11                    0.5.2-3      GNU libidn library, implementation
ii  libncursesw5                5.4-4        Shared libraries for terminal hand
ii  libsasl2                    2.1.19-1.5   Authentication abstraction library

-- no debconf information

-- 
Daniel Jacobowitz
CodeSourcery, LLC

----- End forwarded message -----

-- 
ciao,
Marco