From: Richard Russon Date: Sat, 8 Sep 2018 15:05:42 +0000 (+0100) Subject: move Context.mtime X-Git-Tag: 2019-10-25~657^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e83a0072d04d028e761012a0cb1427e56ada5a0a;p=neomutt move Context.mtime --- diff --git a/context.h b/context.h index 6bd49b9f7..4f81fe1cd 100644 --- 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 */ diff --git a/mailbox.c b/mailbox.c index 92e1441d7..9708047eb 100644 --- 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); } } diff --git a/mailbox.h b/mailbox.h index 334caaf94..973e7de3b 100644 --- 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. */ diff --git a/maildir/mh.c b/maildir/mh.c index 925513265..b70ce6030 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -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 b7a3fd997..4482a37c5 100644 --- 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" diff --git a/mbox/mbox.c b/mbox/mbox.c index cf0df20c6..e954cdc86 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -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; } diff --git a/mutt_thread.h b/mutt_thread.h index 5a278402f..16fb04708 100644 --- a/mutt_thread.h +++ b/mutt_thread.h @@ -27,6 +27,7 @@ struct Context; struct Header; +struct Mailbox; struct MuttThread; /* These Config Variables are only used in mutt_thread.c */ diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index bbda66f16..787fb5539 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -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);