-
- snprintf (path, sizeof (path), "%s/new", tmp->path);
- if ((dirp = opendir (path)) == NULL)
- {
- tmp->magic = 0;
- break;
- }
- tmp->msgcount = 0;
- tmp->msg_unread = 0;
- tmp->new = 0;
- while ((de = readdir (dirp)) != NULL)
- {
- char *p;
- if (*de->d_name != '.' &&
- (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
- {
- /* one new and undeleted message is enough */
- if (tmp->new == 0)
- {
- BuffyCount++;
- tmp->has_new = tmp->new = 1;
- if (SidebarWidth == 0 || !option (OPTMBOXPANE))
- /* if sidebar invisible -> done */
- break;
- }
- tmp->msgcount++;
- tmp->msg_unread++;
- tmp->new++;
- }
- }
- closedir (dirp);
-
- if (SidebarWidth > 0 && option (OPTMBOXPANE))
- {
- /* only count total mail if sidebar visible */
- snprintf (path, sizeof (path), "%s/cur", tmp->path);
- if ((dirp = opendir (path)) == NULL)
- {
+ /* only check on force or $mail_check reached */
+ if (force == 1 || (now - last1 >= BuffyTimeout)) {
+ snprintf (path, sizeof (path), "%s/new", tmp->path);
+ if ((dirp = opendir (path)) == NULL) {