isync

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

commit d00a65bebda0033829789050afb7cc0475cb0db1
parent dd22bd3f22b967646d5d93ad5fdfb6793aede45c
Author: Michael Elkins <me@mutt.org>
Date:   Thu, 17 Jan 2002 19:33:25 +0000

don't bother renaming the message file if we are about to unlink() it

Diffstat:
Msync.c | 63+++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 35 insertions(+), 28 deletions(-)

diff --git a/sync.c b/sync.c @@ -200,36 +200,43 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags, mbox->deleted++; cur->flags |= (tmp->flags & ~(D_RECENT | D_DRAFT)); - /* generate old path */ - snprintf (path, sizeof (path), "%s/%s/%s", - mbox->path, cur->new ? "new" : "cur", cur->file); - - /* truncate old flags (if present) */ - p = strchr (cur->file, ':'); - if (p) - *p = 0; - - /* generate new path - always put this in the cur/ directory - * because its no longer new + /* don't bother renaming the file if we are just going to + * remove it later. */ - snprintf (newpath, sizeof (newpath), "%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" : "", - (cur->flags & D_DELETED) ? "T" : ""); - - if (rename (path, newpath)) - { - perror ("rename"); - return -1; - } - else + if ((cur->flags & D_DELETED) == 0 || (flags & SYNC_EXPUNGE) == 0) { - /* update the filename in the msg struct */ - p = strrchr (newpath, '/'); - free (cur->file); - cur->file = strdup (p + 1); + /* generate old path */ + snprintf (path, sizeof (path), "%s/%s/%s", + mbox->path, cur->new ? "new" : "cur", cur->file); + + /* truncate old flags (if present) */ + p = strchr (cur->file, ':'); + if (p) + *p = 0; + + /* generate new path - always put this in the cur/ directory + * because its no longer new + */ + snprintf (newpath, sizeof (newpath), "%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" : "", + (cur->flags & D_DELETED) ? "T" : ""); + + if (rename (path, newpath)) + { + perror ("rename"); + return -1; + } + else + { + /* update the filename in the msg struct */ + p = strrchr (newpath, '/'); + free (cur->file); + cur->file = strdup (p + 1); + cur->new = 0; /* not any more */ + } } } }