]> granicus.if.org Git - neomutt/commitdiff
move Context.mtime
authorRichard Russon <rich@flatcap.org>
Sat, 8 Sep 2018 15:05:42 +0000 (16:05 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 9 Sep 2018 15:12:46 +0000 (16:12 +0100)
context.h
mailbox.c
mailbox.h
maildir/mh.c
main.c
mbox/mbox.c
mutt_thread.h
notmuch/mutt_notmuch.c

index 6bd49b9f7029963aaa1e5e7c4a3adcf9c24c727a..4f81fe1cd74f079f08e5bee3303613e7797b73f7 100644 (file)
--- a/context.h
+++ b/context.h
@@ -33,7 +33,6 @@
  */
 struct Context
 {
-  struct timespec mtime;
   off_t vsize;
   char *pattern;                 /**< limit pattern string */
   struct Pattern *limit_pattern; /**< compiled limit pattern */
index 92e1441d7a189eb3ae9ba6932049d1da28a5d60e..9708047eb639a0f25f900575fc46fedaf85d5d5c 100644 (file)
--- a/mailbox.c
+++ b/mailbox.c
@@ -382,7 +382,7 @@ static int mailbox_mbox_check(struct Mailbox *mailbox, struct stat *sb, bool che
       mailbox->msg_count = ctx->mailbox->msg_count;
       mailbox->msg_unread = ctx->mailbox->msg_unread;
       mailbox->msg_flagged = ctx->mailbox->msg_flagged;
-      mailbox->stats_last_checked = ctx->mtime;
+      mailbox->stats_last_checked = ctx->mailbox->mtime;
       mx_mbox_close(&ctx, NULL);
     }
   }
index 334caaf948414e8abfe33d4df8373c5af9e3329a..973e7de3b8b7eac0b740aa8f0ea2f8ed838a2bb0 100644 (file)
--- a/mailbox.h
+++ b/mailbox.h
@@ -94,6 +94,7 @@ struct Mailbox
   bool notified;             /**< user has been notified */
   enum MailboxType magic;    /**< mailbox type */
   bool newly_created;        /**< mbox or mmdf just popped into existence */
+  struct timespec mtime;
   struct timespec last_visited;       /**< time of last exit from this mailbox */
   struct timespec stats_last_checked; /**< mtime of mailbox the last time stats where checked. */
 
index 9255132654fe57505d1db8225d43587b2be81de2..b70ce60306f367aef15f697a0cb0a3ea8d4ea29b 100644 (file)
@@ -869,7 +869,7 @@ static void maildir_update_mtime(struct Context *ctx)
   }
 
   if (stat(buf, &st) == 0)
-    mutt_get_stat_timespec(&ctx->mtime, &st, MUTT_STAT_MTIME);
+    mutt_get_stat_timespec(&ctx->mailbox->mtime, &st, MUTT_STAT_MTIME);
 }
 
 /**
@@ -2344,7 +2344,7 @@ static int maildir_mbox_check(struct Context *ctx, int *index_hint)
     return -1;
 
   /* determine which subdirectories need to be scanned */
-  if (mutt_stat_timespec_compare(&st_new, MUTT_STAT_MTIME, &ctx->mtime) > 0)
+  if (mutt_stat_timespec_compare(&st_new, MUTT_STAT_MTIME, &ctx->mailbox->mtime) > 0)
     changed = 1;
   if (mutt_stat_timespec_compare(&st_cur, MUTT_STAT_MTIME, &data->mtime_cur) > 0)
     changed |= 2;
@@ -2365,7 +2365,7 @@ static int maildir_mbox_check(struct Context *ctx, int *index_hint)
 #endif
   {
     mutt_get_stat_timespec(&data->mtime_cur, &st_cur, MUTT_STAT_MTIME);
-    mutt_get_stat_timespec(&ctx->mtime, &st_new, MUTT_STAT_MTIME);
+    mutt_get_stat_timespec(&ctx->mailbox->mtime, &st_new, MUTT_STAT_MTIME);
   }
 
   /* do a fast scan of just the filenames in
@@ -2523,7 +2523,7 @@ static int mh_mbox_check(struct Context *ctx, int *index_hint)
   if (i == -1 && stat(buf, &st_cur) == -1)
     modified = true;
 
-  if ((mutt_stat_timespec_compare(&st, MUTT_STAT_MTIME, &ctx->mtime) > 0) ||
+  if ((mutt_stat_timespec_compare(&st, MUTT_STAT_MTIME, &ctx->mailbox->mtime) > 0) ||
       (mutt_stat_timespec_compare(&st_cur, MUTT_STAT_MTIME, &data->mtime_cur) > 0))
   {
     modified = true;
@@ -2545,7 +2545,7 @@ static int mh_mbox_check(struct Context *ctx, int *index_hint)
 #endif
   {
     mutt_get_stat_timespec(&data->mtime_cur, &st_cur, MUTT_STAT_MTIME);
-    mutt_get_stat_timespec(&ctx->mtime, &st, MUTT_STAT_MTIME);
+    mutt_get_stat_timespec(&ctx->mailbox->mtime, &st, MUTT_STAT_MTIME);
   }
 
   md = NULL;
diff --git a/main.c b/main.c
index b7a3fd997e50a97276f1611eacfb67f7736904f1..4482a37c593dd8a67822a3acfee024d6eeb0c3ba 100644 (file)
--- a/main.c
+++ b/main.c
@@ -50,6 +50,7 @@
 #include "alias.h"
 #include "browser.h"
 #include "color.h"
+#include "context.h"
 #include "curs_lib.h"
 #include "curs_main.h"
 #include "globals.h"
index cf0df20c6b93f2947b84eac90a156eb5d560c6d6..e954cdc86ef8c2f9ed812ca36c281fcc68dac985 100644 (file)
@@ -210,7 +210,7 @@ static int mmdf_parse_mailbox(struct Context *ctx)
     return -1;
   }
   mutt_get_stat_timespec(&mdata->atime, &sb, MUTT_STAT_ATIME);
-  mutt_get_stat_timespec(&ctx->mtime, &sb, MUTT_STAT_MTIME);
+  mutt_get_stat_timespec(&ctx->mailbox->mtime, &sb, MUTT_STAT_MTIME);
   ctx->mailbox->size = sb.st_size;
 
   buf[sizeof(buf) - 1] = '\0';
@@ -376,7 +376,7 @@ static int mbox_parse_mailbox(struct Context *ctx)
   }
 
   ctx->mailbox->size = sb.st_size;
-  mutt_get_stat_timespec(&ctx->mtime, &sb, MUTT_STAT_MTIME);
+  mutt_get_stat_timespec(&ctx->mailbox->mtime, &sb, MUTT_STAT_MTIME);
   mutt_get_stat_timespec(&mdata->atime, &sb, MUTT_STAT_ATIME);
 
   if (!ctx->mailbox->readonly)
@@ -643,17 +643,17 @@ static int mbox_mbox_close(struct Context *ctx)
 
   /* fix up the times so mailbox won't get confused */
   if (ctx->peekonly && ctx->mailbox->path &&
-      (mutt_timespec_compare(&ctx->mtime, &mdata->atime) > 0))
+      (mutt_timespec_compare(&ctx->mailbox->mtime, &mdata->atime) > 0))
   {
 #ifdef HAVE_UTIMENSAT
     struct timespec ts[2];
     ts[0] = mdata->atime;
-    ts[1] = ctx->mtime;
+    ts[1] = ctx->mailbox->mtime;
     utimensat(0, ctx->mailbox->path, ts, 0);
 #else
     struct utimbuf ut;
     ut.actime = mdata->atime.tv_sec;
-    ut.modtime = ctx->mtime.tv_sec;
+    ut.modtime = ctx->mailbox->mtime.tv_sec;
     utime(ctx->mailbox->path, &ut);
 #endif
   }
@@ -965,7 +965,7 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint)
 
   if (stat(ctx->mailbox->path, &st) == 0)
   {
-    if ((mutt_stat_timespec_compare(&st, MUTT_STAT_MTIME, &ctx->mtime) == 0) &&
+    if ((mutt_stat_timespec_compare(&st, MUTT_STAT_MTIME, &ctx->mailbox->mtime) == 0) &&
         st.st_size == ctx->mailbox->size)
     {
       return 0;
@@ -974,7 +974,7 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint)
     if (st.st_size == ctx->mailbox->size)
     {
       /* the file was touched, but it is still the same length, so just exit */
-      mutt_get_stat_timespec(&ctx->mtime, &st, MUTT_STAT_MTIME);
+      mutt_get_stat_timespec(&ctx->mailbox->mtime, &st, MUTT_STAT_MTIME);
       return 0;
     }
 
index 5a278402fd33c4ff4fb7791b23bc230cc510ac6a..16fb047088168ddb3d576d4130e7737e2874a567 100644 (file)
@@ -27,6 +27,7 @@
 
 struct Context;
 struct Header;
+struct Mailbox;
 struct MuttThread;
 
 /* These Config Variables are only used in mutt_thread.c */
index bbda66f16ddc9ea67df66b79b3f09f0c9efd070c..787fb5539fb0d67490c2a9835334623d580d6616 100644 (file)
@@ -1868,8 +1868,8 @@ int nm_read_entire_thread(struct Context *ctx, struct Header *h)
   notmuch_query_set_sort(q, NOTMUCH_SORT_NEWEST_FIRST);
 
   read_threads_query(ctx, q, true, 0);
-  ctx->mtime.tv_sec = time(NULL);
-  ctx->mtime.tv_nsec = 0;
+  ctx->mailbox->mtime.tv_sec = time(NULL);
+  ctx->mailbox->mtime.tv_nsec = 0;
   rc = 0;
 
   if (ctx->mailbox->msg_count > data->oldmsgcount)
@@ -2080,8 +2080,8 @@ done:
     release_db(data);
   if (hdr->changed)
   {
-    ctx->mtime.tv_sec = time(NULL);
-    ctx->mtime.tv_nsec = 0;
+    ctx->mailbox->mtime.tv_sec = time(NULL);
+    ctx->mailbox->mtime.tv_nsec = 0;
   }
   mutt_debug(1, "nm: tags modify done [rc=%d]\n", rc);
   return rc;
@@ -2185,8 +2185,8 @@ int nm_update_filename(struct Context *ctx, const char *old, const char *new,
 
   if (!is_longrun(data))
     release_db(data);
-  ctx->mtime.tv_sec = time(NULL);
-  ctx->mtime.tv_nsec = 0;
+  ctx->mailbox->mtime.tv_sec = time(NULL);
+  ctx->mailbox->mtime.tv_nsec = 0;
   return rc;
 }
 
@@ -2479,8 +2479,8 @@ static int nm_mbox_open(struct Context *ctx)
   if (!is_longrun(data))
     release_db(data);
 
-  ctx->mtime.tv_sec = time(NULL);
-  ctx->mtime.tv_nsec = 0;
+  ctx->mailbox->mtime.tv_sec = time(NULL);
+  ctx->mailbox->mtime.tv_nsec = 0;
 
   mx_update_context(ctx, ctx->mailbox->msg_count);
   data->oldmsgcount = 0;
@@ -2522,13 +2522,14 @@ static int nm_mbox_check(struct Context *ctx, int *index_hint)
   if (!data || (get_database_mtime(data, &mtime) != 0))
     return -1;
 
-  if (ctx->mtime.tv_sec >= mtime)
+  if (ctx->mailbox->mtime.tv_sec >= mtime)
   {
-    mutt_debug(2, "nm: check unnecessary (db=%lu ctx=%lu)\n", mtime, ctx->mtime);
+    mutt_debug(2, "nm: check unnecessary (db=%lu ctx=%lu)\n", mtime,
+               ctx->mailbox->mtime);
     return 0;
   }
 
-  mutt_debug(1, "nm: checking (db=%lu ctx=%lu)\n", mtime, ctx->mtime);
+  mutt_debug(1, "nm: checking (db=%lu ctx=%lu)\n", mtime, ctx->mailbox->mtime);
 
   q = get_query(data, false);
   if (!q)
@@ -2617,8 +2618,8 @@ done:
   if (!is_longrun(data))
     release_db(data);
 
-  ctx->mtime.tv_sec = time(NULL);
-  ctx->mtime.tv_nsec = 0;
+  ctx->mailbox->mtime.tv_sec = time(NULL);
+  ctx->mailbox->mtime.tv_nsec = 0;
 
   mutt_debug(1, "nm: ... check done [count=%d, new_flags=%d, occult=%d]\n",
              ctx->mailbox->msg_count, new_flags, occult);
@@ -2709,8 +2710,8 @@ static int nm_mbox_sync(struct Context *ctx, int *index_hint)
     release_db(data);
   if (changed)
   {
-    ctx->mtime.tv_sec = time(NULL);
-    ctx->mtime.tv_nsec = 0;
+    ctx->mailbox->mtime.tv_sec = time(NULL);
+    ctx->mailbox->mtime.tv_nsec = 0;
   }
 
   mutt_debug(1, "nm: .... sync done [rc=%d]\n", rc);