commit a4f2725bad38cdde2edc06e7f2308d49a6609d9e
parent 2012aadc5b4d819424f245fdb3f18f18113c5529
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date: Sat, 28 Dec 2002 04:12:07 +0000
- update isyncmaxuid properly
Diffstat:
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/TODO b/TODO
@@ -1,7 +1,5 @@
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
IMAP session. need to handled those asynchronous notifications properly.
diff --git a/src/maildir.c b/src/maildir.c
@@ -198,9 +198,6 @@ maildir_open (const char *path, int flags)
if (read_uid (m->path, "isyncmaxuid", &m->maxuid) == -1)
goto err;
- if (flags & OPEN_FAST)
- return m;
-
snprintf (buf, sizeof (buf), "%s/isyncuidmap", m->path);
m->db = dbm_open (buf, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (m->db == NULL)
@@ -209,6 +206,9 @@ maildir_open (const char *path, int flags)
goto err;
}
+ if (flags & OPEN_FAST)
+ return m;
+
cur = &m->msgs;
for (; count < 2; count++)
{
diff --git a/src/sync.c b/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)
{
mbox->maxuid = imap->maxuid;
- if (maildir_update_maxuid (mbox))
- return -1;
}
/* 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->uid = imap_append_message (imap, fd, cur);
- /* if the server gave us back a uid, update the db */
if (cur->uid != (unsigned int) -1) {
+ /* update the db */
set_uid (mbox->db, cur->file, cur->uid);
if (!cur->uid)
printf("warning: no uid for new messge %s\n", cur->file);
+ else if (cur->uid > mbox->maxuid)
+ mbox->maxuid = cur->uid;
}
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 */
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);
+ if (maildir_update_maxuid (mbox))
+ return -1;
+
return 0;
}