Lines 214-220
Link Here
|
214 |
DRIVER *ret = NIL; |
214 |
DRIVER *ret = NIL; |
215 |
char *t,file[MAILTMPLEN]; |
215 |
char *t,file[MAILTMPLEN]; |
216 |
struct stat sbuf; |
216 |
struct stat sbuf; |
217 |
time_t tp[2]; |
217 |
struct utimbuf tp; |
218 |
errno = EINVAL; /* assume invalid argument */ |
218 |
errno = EINVAL; /* assume invalid argument */ |
219 |
/* must be non-empty file */ |
219 |
/* must be non-empty file */ |
220 |
if ((t = dummy_file (file,name)) && !stat (t,&sbuf)) { |
220 |
if ((t = dummy_file (file,name)) && !stat (t,&sbuf)) { |
Lines 226-234
Link Here
|
226 |
close (fd); /* close the file */ |
226 |
close (fd); /* close the file */ |
227 |
/* \Marked status? */ |
227 |
/* \Marked status? */ |
228 |
if ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) { |
228 |
if ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) { |
229 |
tp[0] = sbuf.st_atime; /* yes, preserve atime and mtime */ |
229 |
tp.actime = sbuf.st_atime; /* yes, preserve atime and mtime */ |
230 |
tp[1] = sbuf.st_mtime; |
230 |
tp.modtime = sbuf.st_mtime; |
231 |
utime (file,tp); /* set the times */ |
231 |
utime (file,&tp); /* set the times */ |
232 |
} |
232 |
} |
233 |
} |
233 |
} |
234 |
} |
234 |
} |
Lines 884-890
Link Here
|
884 |
int fd; |
884 |
int fd; |
885 |
char *s,file[MAILTMPLEN]; |
885 |
char *s,file[MAILTMPLEN]; |
886 |
DOTLOCK lock; |
886 |
DOTLOCK lock; |
887 |
time_t tp[2]; |
887 |
struct utimbuf tp; |
888 |
unsigned long i,j; |
888 |
unsigned long i,j; |
889 |
MESSAGECACHE *elt; |
889 |
MESSAGECACHE *elt; |
890 |
long ret = T; |
890 |
long ret = T; |
Lines 990-1001
Link Here
|
990 |
mail_free_searchset (&source); |
990 |
mail_free_searchset (&source); |
991 |
mail_free_searchset (&dest); |
991 |
mail_free_searchset (&dest); |
992 |
} |
992 |
} |
993 |
tp[1] = time (0); /* set mtime to now */ |
993 |
tp.modtime = time (0); /* set mtime to now */ |
994 |
if (ret) tp[0] = tp[1] - 1; /* set atime to now-1 if successful copy */ |
994 |
if (ret) tp.actime = tp.modtime - 1; /* set atime to now-1 if successful copy */ |
995 |
else tp[0] = /* else preserve \Marked status */ |
995 |
else tp.actime = /* else preserve \Marked status */ |
996 |
((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) ? |
996 |
((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) ? |
997 |
sbuf.st_atime : tp[1]; |
997 |
sbuf.st_atime : tp.modtime; |
998 |
utime (file,tp); /* set the times */ |
998 |
utime (file,&tp); /* set the times */ |
999 |
unix_unlock (fd,NIL,&lock); /* unlock and close mailbox */ |
999 |
unix_unlock (fd,NIL,&lock); /* unlock and close mailbox */ |
1000 |
if (tstream) { /* update last UID if we can */ |
1000 |
if (tstream) { /* update last UID if we can */ |
1001 |
UNIXLOCAL *local = (UNIXLOCAL *) tstream->local; |
1001 |
UNIXLOCAL *local = (UNIXLOCAL *) tstream->local; |
Lines 1029-1035
Link Here
|
1029 |
int fd; |
1029 |
int fd; |
1030 |
unsigned long i; |
1030 |
unsigned long i; |
1031 |
char *flags,*date,buf[BUFLEN],tmp[MAILTMPLEN],file[MAILTMPLEN]; |
1031 |
char *flags,*date,buf[BUFLEN],tmp[MAILTMPLEN],file[MAILTMPLEN]; |
1032 |
time_t tp[2]; |
1032 |
struct utimbuf tp; |
1033 |
FILE *sf,*df; |
1033 |
FILE *sf,*df; |
1034 |
MESSAGECACHE elt; |
1034 |
MESSAGECACHE elt; |
1035 |
DOTLOCK lock; |
1035 |
DOTLOCK lock; |
Lines 1143-1162
Link Here
|
1143 |
} |
1143 |
} |
1144 |
fstat (fd,&sbuf); /* get current file size */ |
1144 |
fstat (fd,&sbuf); /* get current file size */ |
1145 |
rewind (sf); |
1145 |
rewind (sf); |
1146 |
tp[1] = time (0); /* set mtime to now */ |
1146 |
tp.modtime = time (0); /* set mtime to now */ |
1147 |
/* write all messages */ |
1147 |
/* write all messages */ |
1148 |
if (!unix_append_msgs (tstream,sf,df,au ? dst : NIL) || |
1148 |
if (!unix_append_msgs (tstream,sf,df,au ? dst : NIL) || |
1149 |
(fflush (df) == EOF) || fsync (fd)) { |
1149 |
(fflush (df) == EOF) || fsync (fd)) { |
1150 |
sprintf (buf,"Message append failed: %s",strerror (errno)); |
1150 |
sprintf (buf,"Message append failed: %s",strerror (errno)); |
1151 |
MM_LOG (buf,ERROR); |
1151 |
MM_LOG (buf,ERROR); |
1152 |
ftruncate (fd,sbuf.st_size); |
1152 |
ftruncate (fd,sbuf.st_size); |
1153 |
tp[0] = /* preserve \Marked status */ |
1153 |
tp.actime = /* preserve \Marked status */ |
1154 |
((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) ? |
1154 |
((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) ? |
1155 |
sbuf.st_atime : tp[1]; |
1155 |
sbuf.st_atime : tp.modtime; |
1156 |
ret = NIL; /* return error */ |
1156 |
ret = NIL; /* return error */ |
1157 |
} |
1157 |
} |
1158 |
else tp[0] = tp[1] - 1; /* set atime to now-1 if successful copy */ |
1158 |
else tp.actime = tp.modtime - 1; /* set atime to now-1 if successful copy */ |
1159 |
utime (file,tp); /* set the times */ |
1159 |
utime (file,&tp); /* set the times */ |
1160 |
fclose (sf); /* done with scratch file */ |
1160 |
fclose (sf); /* done with scratch file */ |
1161 |
/* force UIDVALIDITY assignment now */ |
1161 |
/* force UIDVALIDITY assignment now */ |
1162 |
if (tstream && !tstream->uid_validity) tstream->uid_validity = time (0); |
1162 |
if (tstream && !tstream->uid_validity) tstream->uid_validity = time (0); |
Lines 1397-1427
Link Here
|
1397 |
{ |
1397 |
{ |
1398 |
if (stream) { /* need to muck with times? */ |
1398 |
if (stream) { /* need to muck with times? */ |
1399 |
struct stat sbuf; |
1399 |
struct stat sbuf; |
1400 |
time_t tp[2]; |
1400 |
struct utimbuf tp; |
1401 |
time_t now = time (0); |
1401 |
time_t now = time (0); |
1402 |
fstat (fd,&sbuf); /* get file times */ |
1402 |
fstat (fd,&sbuf); /* get file times */ |
1403 |
if (LOCAL->ld >= 0) { /* yes, readwrite session? */ |
1403 |
if (LOCAL->ld >= 0) { /* yes, readwrite session? */ |
1404 |
tp[0] = now; /* set atime to now */ |
1404 |
tp.actime = now; /* set atime to now */ |
1405 |
/* set mtime to (now - 1) if necessary */ |
1405 |
/* set mtime to (now - 1) if necessary */ |
1406 |
tp[1] = (now > sbuf.st_mtime) ? sbuf.st_mtime : now - 1; |
1406 |
tp.modtime = (now > sbuf.st_mtime) ? sbuf.st_mtime : now - 1; |
1407 |
} |
1407 |
} |
1408 |
else if (stream->recent) { /* readonly with recent messages */ |
1408 |
else if (stream->recent) { /* readonly with recent messages */ |
1409 |
if ((sbuf.st_atime >= sbuf.st_mtime) || |
1409 |
if ((sbuf.st_atime >= sbuf.st_mtime) || |
1410 |
(sbuf.st_atime >= sbuf.st_ctime)) |
1410 |
(sbuf.st_atime >= sbuf.st_ctime)) |
1411 |
/* keep past mtime, whack back atime */ |
1411 |
/* keep past mtime, whack back atime */ |
1412 |
tp[0] = (tp[1] = (sbuf.st_mtime < now) ? sbuf.st_mtime : now) - 1; |
1412 |
tp.actime = (tp.modtime = (sbuf.st_mtime < now) ? sbuf.st_mtime : now) - 1; |
1413 |
else now = 0; /* no time change needed */ |
1413 |
else now = 0; /* no time change needed */ |
1414 |
} |
1414 |
} |
1415 |
/* readonly with no recent messages */ |
1415 |
/* readonly with no recent messages */ |
1416 |
else if ((sbuf.st_atime < sbuf.st_mtime) || |
1416 |
else if ((sbuf.st_atime < sbuf.st_mtime) || |
1417 |
(sbuf.st_atime < sbuf.st_ctime)) { |
1417 |
(sbuf.st_atime < sbuf.st_ctime)) { |
1418 |
tp[0] = now; /* set atime to now */ |
1418 |
tp.actime = now; /* set atime to now */ |
1419 |
/* set mtime to (now - 1) if necessary */ |
1419 |
/* set mtime to (now - 1) if necessary */ |
1420 |
tp[1] = (now > sbuf.st_mtime) ? sbuf.st_mtime : now - 1; |
1420 |
tp.modtime = (now > sbuf.st_mtime) ? sbuf.st_mtime : now - 1; |
1421 |
} |
1421 |
} |
1422 |
else now = 0; /* no time change needed */ |
1422 |
else now = 0; /* no time change needed */ |
1423 |
/* set the times, note change */ |
1423 |
/* set the times, note change */ |
1424 |
if (now && !utime (stream->mailbox,tp)) LOCAL->filetime = tp[1]; |
1424 |
if (now && !utime (stream->mailbox,&tp)) LOCAL->filetime = tp.modtime; |
1425 |
} |
1425 |
} |
1426 |
flock (fd,LOCK_UN); /* release flock'ers */ |
1426 |
flock (fd,LOCK_UN); /* release flock'ers */ |
1427 |
if (!stream) close (fd); /* close the file if no stream */ |
1427 |
if (!stream) close (fd); /* close the file if no stream */ |
Lines 2075-2081
Link Here
|
2075 |
MESSAGECACHE *elt; |
2075 |
MESSAGECACHE *elt; |
2076 |
UNIXFILE f; |
2076 |
UNIXFILE f; |
2077 |
char *s; |
2077 |
char *s; |
2078 |
time_t tp[2]; |
2078 |
struct utimbuf tp; |
2079 |
long ret,flag; |
2079 |
long ret,flag; |
2080 |
unsigned long i,j; |
2080 |
unsigned long i,j; |
2081 |
unsigned long recent = stream->recent; |
2081 |
unsigned long recent = stream->recent; |
Lines 2245-2253
Link Here
|
2245 |
mail_exists (stream,stream->nmsgs); |
2245 |
mail_exists (stream,stream->nmsgs); |
2246 |
mail_recent (stream,recent); |
2246 |
mail_recent (stream,recent); |
2247 |
/* set atime to now, mtime a second earlier */ |
2247 |
/* set atime to now, mtime a second earlier */ |
2248 |
tp[1] = (tp[0] = time (0)) - 1; |
2248 |
tp.modtime = (tp.actime = time (0)) - 1; |
2249 |
/* set the times, note change */ |
2249 |
/* set the times, note change */ |
2250 |
if (!utime (stream->mailbox,tp)) LOCAL->filetime = tp[1]; |
2250 |
if (!utime (stream->mailbox,&tp)) LOCAL->filetime = tp.modtime; |
2251 |
close (LOCAL->fd); /* close and reopen file */ |
2251 |
close (LOCAL->fd); /* close and reopen file */ |
2252 |
if ((LOCAL->fd = open (stream->mailbox,O_RDWR, |
2252 |
if ((LOCAL->fd = open (stream->mailbox,O_RDWR, |
2253 |
(long) mail_parameters (NIL,GET_MBXPROTECTION,NIL))) |
2253 |
(long) mail_parameters (NIL,GET_MBXPROTECTION,NIL))) |