|
|
@ -25,6 +25,8 @@ |
|
|
|
#include <time.h> |
|
|
|
#include <time.h> |
|
|
|
#include <fcntl.h> |
|
|
|
#include <fcntl.h> |
|
|
|
#include <string.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
#include <sys/stat.h> |
|
|
|
|
|
|
|
#include <errno.h> |
|
|
|
#include "isync.h" |
|
|
|
#include "isync.h" |
|
|
|
|
|
|
|
|
|
|
|
static unsigned int MaildirCount = 0; |
|
|
|
static unsigned int MaildirCount = 0; |
|
|
@ -48,6 +50,7 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags) |
|
|
|
char *p; |
|
|
|
char *p; |
|
|
|
int fd; |
|
|
|
int fd; |
|
|
|
int ret; |
|
|
|
int ret; |
|
|
|
|
|
|
|
struct stat sb; |
|
|
|
|
|
|
|
|
|
|
|
for (cur = mbox->msgs; cur; cur = cur->next) |
|
|
|
for (cur = mbox->msgs; cur; cur = cur->next) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -104,11 +107,23 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (;;) |
|
|
|
|
|
|
|
{ |
|
|
|
/* create new file */ |
|
|
|
/* create new file */ |
|
|
|
snprintf (path, sizeof (path), "%s/tmp/%s.%ld_%d.%d.UID%d", |
|
|
|
snprintf (path, sizeof (path), "%s/tmp/%s.%ld_%d.%d.UID%d", |
|
|
|
mbox->path, Hostname, time (0), MaildirCount++, |
|
|
|
mbox->path, Hostname, time (0), MaildirCount++, |
|
|
|
getpid (), cur->uid); |
|
|
|
getpid (), cur->uid); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (stat (path, &sb)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (errno == ENOENT) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sleep (2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cur->flags) |
|
|
|
if (cur->flags) |
|
|
|
{ |
|
|
|
{ |
|
|
|
/* append flags */ |
|
|
|
/* append flags */ |
|
|
@ -146,10 +161,14 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags) |
|
|
|
|
|
|
|
|
|
|
|
// printf ("moving %s to %s\n", path, newpath);
|
|
|
|
// printf ("moving %s to %s\n", path, newpath);
|
|
|
|
|
|
|
|
|
|
|
|
if (rename (path, newpath)) |
|
|
|
/* its ok if this fails, the next time we sync the message
|
|
|
|
perror ("rename"); |
|
|
|
* will get pulled down |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
if (link (path, newpath)) |
|
|
|
|
|
|
|
perror ("link"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
|
|
|
|
/* always remove the temp file */ |
|
|
|
unlink (path); |
|
|
|
unlink (path); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|