isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 89445383992992f812e44c657061992efb0fe939
parent 32677da976f43cbc2ee2c04814699f622c18ae09
Author: Michael Elkins <me@mutt.org>
Date:   Tue,  9 Jan 2001 20:09:35 +0000

always put changed messages in the cur/ subdirectory since they are no
longer new.

don't set \Seen implicitly for messages in the cur/ folder.  Require the S
flag on the message since Mutt will move Old (unread, but not recent)
messges into cur/.

Diffstat:
Mmaildir.c | 29++++++++++++++++++++---------
Msync.c | 2+-
2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/maildir.c b/maildir.c @@ -195,18 +195,20 @@ maildir_open (const char *path, int fast) p = *cur; p->file = strdup (e->d_name); p->uid = -1; - p->flags = (count == 1) ? D_SEEN : 0; + p->flags = 0; p->new = (count == 0); /* filename format is something like: - * <unique-prefix>.UID<n>:2,<flags> + * <unique-prefix>,U=<n>:2,<flags> * This is completely non-standard, but in order for mail * clients to understand the flags, we have to use the * standard :info as described by the qmail spec */ - s = strstr (p->file, "UID"); + s = strstr (p->file, ",U="); if (!s) - puts ("Warning, no uid for message"); + s = strstr (p->file, "UID"); + if (!s) + puts ("Warning, no UID for message"); else { p->uid = strtol (s + 3, &s, 10); @@ -215,9 +217,16 @@ maildir_open (const char *path, int fast) m->maxuid = p->uid; m->maxuidchanged = 1; } - if (*s && *s != ':') + /* Courier-IMAP names it files + * unique,S=<size>:info + * so we need to put the UID before the size, hence here + * we check for a comma as a valid terminator as well, + * since the format will be + * unique,U=<uid>,S=<size>:info + */ + if (*s && *s != ':' && *s != ',') { - puts ("warning, unable to parse uid"); + puts ("Warning, unable to parse UID"); p->uid = -1; /* reset */ } } @@ -352,9 +361,11 @@ maildir_sync (mailbox_t * mbox) if (p) *p = 0; - /* generate new path */ - snprintf (path, sizeof (path), "%s/%s/%s:2,%s%s%s%s", - mbox->path, (cur->flags & D_SEEN) ? "cur" : "new", + /* generate new path - always put this in the cur/ directory + * because its no longer new + */ + snprintf (path, sizeof (path), "%s/cur/%s:2,%s%s%s%s", + mbox->path, cur->file, (cur->flags & D_FLAGGED) ? "F" : "", (cur->flags & D_ANSWERED) ? "R" : "", (cur->flags & D_SEEN) ? "S" : "", diff --git a/sync.c b/sync.c @@ -152,7 +152,7 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags, unsigned int max_size) for (;;) { /* create new file */ - snprintf (path, sizeof (path), "%s/tmp/%s.%ld_%d.%d.UID%d%s", + snprintf (path, sizeof (path), "%s/tmp/%s.%ld_%d.%d,U=%d%s", mbox->path, Hostname, time (0), MaildirCount++, getpid (), cur->uid, suffix);