Projects STRLCPY neomutt Commits fa6afd8c
🤬
  • Keep track of when we last checked a mbox

    Move stats_last_checked to mbox-specific account data
    
    Failing to do so results in checking the stats anew at each change change-folder.
    This might be slow for mboxes.
  • Loading...
  • Pietro Cerutti committed with GitHub 2 years ago
    fa6afd8c
    1 parent 50ab25a5
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    core/mailbox.h
    skipped 102 lines
    103 103   bool newly_created; ///< Mbox or mmdf just popped into existence
    104 104   struct timespec mtime; ///< Time Mailbox was last changed
    105 105   struct timespec last_visited; ///< Time of last exit from this mailbox
    106  - struct timespec stats_last_checked; ///< Mtime of mailbox the last time stats where checked.
    107 106   
    108 107   const struct MxOps *mx_ops; ///< MXAPI callback functions
    109 108   
    skipped 108 lines
  • ■ ■ ■ ■ ■
    mbox/lib.h
    skipped 46 lines
    47 47   */
    48 48  struct MboxAccountData
    49 49  {
    50  - FILE *fp; ///< Mailbox file
    51  - struct timespec atime; ///< File's last-access time
     50 + FILE *fp; ///< Mailbox file
     51 + struct timespec atime; ///< File's last-access time
     52 + struct timespec stats_last_checked; ///< Mtime of mailbox the last time stats where checked
    52 53   
    53 54   bool locked : 1; ///< is the mailbox locked?
    54 55   bool append : 1; ///< mailbox is opened in append mode
    skipped 14 lines
  • ■ ■ ■ ■ ■ ■
    mbox/mbox.c
    skipped 91 lines
    92 92  }
    93 93   
    94 94  /**
    95  - * mbox_adata_get - Get the private data associated with a Mailbox
    96  - * @param m Mailbox
    97  - * @retval ptr Private data
    98  - */
    99  -static struct MboxAccountData *mbox_adata_get(struct Mailbox *m)
    100  -{
    101  - if (!m)
    102  - return NULL;
    103  - if ((m->type != MUTT_MBOX) && (m->type != MUTT_MMDF))
    104  - return NULL;
    105  - struct Account *a = m->account;
    106  - if (!a)
    107  - return NULL;
    108  - return a->adata;
    109  -}
    110  - 
    111  -/**
    112 95   * init_mailbox - Add Mbox data to the Mailbox
    113 96   * @param m Mailbox
    114 97   * @retval 0 Success
    skipped 11 lines
    126 109   m->account->adata = mbox_adata_new();
    127 110   m->account->adata_free = mbox_adata_free;
    128 111   return 0;
     112 +}
     113 + 
     114 +/**
     115 + * mbox_adata_get - Get the private data associated with a Mailbox
     116 + * @param m Mailbox
     117 + * @retval ptr Private data
     118 + */
     119 +static struct MboxAccountData *mbox_adata_get(struct Mailbox *m)
     120 +{
     121 + if (init_mailbox(m) == -1)
     122 + return NULL;
     123 + return m->account->adata;
    129 124  }
    130 125   
    131 126  /**
    skipped 1690 lines
    1822 1817   if (m->newly_created && ((st.st_ctime != st.st_mtime) || (st.st_ctime != st.st_atime)))
    1823 1818   m->newly_created = false;
    1824 1819   
    1825  - const bool force = flags & (MUTT_MAILBOX_CHECK_FORCE | MUTT_MAILBOX_CHECK_FORCE_STATS);
    1826  - if (force && mutt_file_stat_timespec_compare(&st, MUTT_STAT_MTIME, &m->stats_last_checked) > 0)
     1820 + if (flags & (MUTT_MAILBOX_CHECK_FORCE | MUTT_MAILBOX_CHECK_FORCE_STATS))
    1827 1821   {
    1828  - bool old_peek = m->peekonly;
    1829  - mx_mbox_open(m, MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK);
    1830  - mx_mbox_close(m);
    1831  - m->peekonly = old_peek;
     1822 + struct MboxAccountData *adata = mbox_adata_get(m);
     1823 + if (adata && mutt_file_stat_timespec_compare(&st, MUTT_STAT_MTIME, &adata->stats_last_checked) > 0)
     1824 + {
     1825 + bool old_peek = m->peekonly;
     1826 + mx_mbox_open(m, MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK);
     1827 + mx_mbox_close(m);
     1828 + m->peekonly = old_peek;
     1829 + adata->stats_last_checked.tv_sec = mutt_date_epoch();
     1830 + }
    1832 1831   }
    1833 1832   
    1834 1833   if (m->has_new || m->msg_new)
    skipped 68 lines
Please wait...
Page is in error, reload to recover