View | Details | Raw Unified | Return to bug 80709
Collapse All | Expand All

(-)mail.c (-15 / +8 lines)
Lines 12-41 Link Here
12
static double last_mail_update;
12
static double last_mail_update;
13
13
14
void update_mail_count() {
14
void update_mail_count() {
15
  struct stat buf;
15
  struct stat sbuf;
16
16
17
  if (current_mail_spool == NULL) return;
17
  if (current_mail_spool == NULL) return;
18
18
19
  /* TODO: use that fine file modification notify on Linux 2.4 */
19
  /* TODO: use that fine file modification notify on Linux 2.4 */
20
20
21
  /* don't check mail so often (9.5s is minimum interval) */
21
  /* don't check mail so often (5.5s is minimum interval) */
22
  if (current_update_time - last_mail_update < 9.5)
22
  if (current_update_time - last_mail_update < 5.5)
23
    return;
23
    return;
24
  else
24
  else
25
    last_mail_update = current_update_time;
25
    last_mail_update = current_update_time;
26
26
27
  if (stat(current_mail_spool, &buf)) {
27
  if (stat(current_mail_spool, &sbuf) == -1) {
28
    static int rep;
29
    if (!rep) {
30
      ERR("can't stat %s: %s", current_mail_spool, strerror(errno));
28
      ERR("can't stat %s: %s", current_mail_spool, strerror(errno));
31
      rep = 1;
29
      return;
32
    }
33
    return;
34
  }
30
  }
35
31
36
#if HAVE_DIRENT_H
32
#if HAVE_DIRENT_H
37
  /* maildir format */
33
  /* maildir format */
38
	if (S_ISDIR(buf.st_mode)){
34
	if (S_ISDIR(sbuf.st_mode)){
39
		DIR *dir;
35
		DIR *dir;
40
		char *dirname;
36
		char *dirname;
41
		struct dirent *dirent;
37
		struct dirent *dirent;
Lines 95-101 Link Here
95
	/* mbox format */
91
	/* mbox format */
96
92
97
93
98
  if (buf.st_mtime != last_mail_mtime) {
94
  if (sbuf.st_ctime != last_mail_mtime) {
99
    /* yippee, modification time has changed, let's read mail count! */
95
    /* yippee, modification time has changed, let's read mail count! */
100
    static int rep;
96
    static int rep;
101
    FILE *fp;
97
    FILE *fp;
Lines 127-133 Link Here
127
            reading_status = 1;
123
            reading_status = 1;
128
        }
124
        }
129
      }
125
      }
130
      else {
131
        if (reading_status && strncmp(buf, "X-Mozilla-Status:", 17) == 0) {
126
        if (reading_status && strncmp(buf, "X-Mozilla-Status:", 17) == 0) {
132
          /* check that mail isn't already read */
127
          /* check that mail isn't already read */
133
          if (strchr(buf+21, '0'))
128
          if (strchr(buf+21, '0'))
Lines 144-150 Link Here
144
          reading_status = 0;
139
          reading_status = 0;
145
          continue;
140
          continue;
146
        }
141
        }
147
      }
148
142
149
      /* skip until \n */
143
      /* skip until \n */
150
      while (strchr(buf, '\n') == NULL && !feof(fp))
144
      while (strchr(buf, '\n') == NULL && !feof(fp))
Lines 155-161 Link Here
155
149
156
    if (reading_status) info.new_mail_count++;
150
    if (reading_status) info.new_mail_count++;
157
151
158
    last_mail_mtime = buf.st_mtime;
152
    last_mail_mtime = sbuf.st_mtime;
159
  }
153
  }
160
}
154
}
161
155
162
-------------------- patch -----------------------------

Return to bug 80709