Browse Source

- update isyncmaxuid properly

0.9
Oswald Buddenhagen 22 years ago
parent
commit
a4f2725bad
  1. 2
      TODO
  2. 6
      src/maildir.c
  3. 11
      src/sync.c

2
TODO

@ -1,7 +1,5 @@
add support for syncing with other: and shared: via NAMESPACE add support for syncing with other: and shared: via NAMESPACE
--fast downloads the last message again if no new messages have arrived
isync gets confused when new mail is delivered while in the middle of an isync gets confused when new mail is delivered while in the middle of an
IMAP session. need to handled those asynchronous notifications properly. IMAP session. need to handled those asynchronous notifications properly.

6
src/maildir.c

@ -198,9 +198,6 @@ maildir_open (const char *path, int flags)
if (read_uid (m->path, "isyncmaxuid", &m->maxuid) == -1) if (read_uid (m->path, "isyncmaxuid", &m->maxuid) == -1)
goto err; goto err;
if (flags & OPEN_FAST)
return m;
snprintf (buf, sizeof (buf), "%s/isyncuidmap", m->path); snprintf (buf, sizeof (buf), "%s/isyncuidmap", m->path);
m->db = dbm_open (buf, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); m->db = dbm_open (buf, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (m->db == NULL) if (m->db == NULL)
@ -209,6 +206,9 @@ maildir_open (const char *path, int flags)
goto err; goto err;
} }
if (flags & OPEN_FAST)
return m;
cur = &m->msgs; cur = &m->msgs;
for (; count < 2; count++) for (; count < 2; count++)
{ {

11
src/sync.c

@ -94,8 +94,6 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
if (mbox->maxuid == 0 || imap->maxuid > mbox->maxuid) if (mbox->maxuid == 0 || imap->maxuid > mbox->maxuid)
{ {
mbox->maxuid = imap->maxuid; mbox->maxuid = imap->maxuid;
if (maildir_update_maxuid (mbox))
return -1;
} }
/* if we are --fast mode, the mailbox wont have been loaded, so /* if we are --fast mode, the mailbox wont have been loaded, so
@ -153,11 +151,13 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
cur->size = sb.st_size; cur->size = sb.st_size;
cur->uid = imap_append_message (imap, fd, cur); cur->uid = imap_append_message (imap, fd, cur);
/* if the server gave us back a uid, update the db */
if (cur->uid != (unsigned int) -1) { if (cur->uid != (unsigned int) -1) {
/* update the db */
set_uid (mbox->db, cur->file, cur->uid); set_uid (mbox->db, cur->file, cur->uid);
if (!cur->uid) if (!cur->uid)
printf("warning: no uid for new messge %s\n", cur->file); printf("warning: no uid for new messge %s\n", cur->file);
else if (cur->uid > mbox->maxuid)
mbox->maxuid = cur->uid;
} }
close (fd); close (fd);
@ -373,6 +373,8 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
{ {
/* update the db with the UID mapping for this file */ /* update the db with the UID mapping for this file */
set_uid (mbox->db, p + 1, cur->uid); set_uid (mbox->db, p + 1, cur->uid);
if (cur->uid > mbox->maxuid)
mbox->maxuid = cur->uid;
} }
} }
@ -383,5 +385,8 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
info (" %d messages\n", fetched); info (" %d messages\n", fetched);
if (maildir_update_maxuid (mbox))
return -1;
return 0; return 0;
} }

Loading…
Cancel
Save