diff options
-rw-r--r-- | driver.c | 9 | ||||
-rw-r--r-- | fetchmail.c | 6 | ||||
-rw-r--r-- | fetchmail.h | 2 | ||||
-rw-r--r-- | pop3.c | 6 | ||||
-rw-r--r-- | uid.c | 41 |
5 files changed, 33 insertions, 31 deletions
@@ -716,9 +716,6 @@ struct method *proto; * server now. */ - /* nuke it from the unseen-messages list */ - delete_uid(&queryctl->unseen, num); - /* maybe we delete this message now? */ if (protocol->delete && !queryctl->keep @@ -732,7 +729,11 @@ struct method *proto; goto cleanUp; } else if (outlevel > O_SILENT && outlevel < O_VERBOSE) - fprintf(stderr, " not flushed\n", num); + { + /* nuke it from the unseen-messages list */ + delete_uid(&queryctl->newsaved, num); + fprintf(stderr, " not flushed\n", num); + } } /* remove all messages flagged for deletion */ diff --git a/fetchmail.c b/fetchmail.c index d65de5f4..e3369d2b 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -539,19 +539,19 @@ struct hostrec *queryctl; else printf(" Messages will be SMTP-forwarded to '%s'\n", queryctl->smtphost); if (queryctl->protocol > P_POP2) - if (!queryctl->saved) + if (!queryctl->oldsaved) printf(" No UIDs saved from this host.\n"); else { struct idlist *idp; int count = 0; - for (idp = hostp->saved; idp; idp = idp->next) + for (idp = hostp->oldsaved; idp; idp = idp->next) ++count; printf(" %d UIDs saved.\n", count); if (outlevel == O_VERBOSE) - for (idp = hostp->saved; idp; idp = idp->next) + for (idp = hostp->oldsaved; idp; idp = idp->next) fprintf(stderr, "\t%s %s\n", hostp->servername, idp->id); } } diff --git a/fetchmail.h b/fetchmail.h index 5a146ce8..6c7eced3 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -88,7 +88,7 @@ struct hostrec int skip; /* unseen, previous state of mailbox (initially from .fetchids) */ - struct idlist *saved, *unseen; + struct idlist *oldsaved, *newsaved; /* internal use */ int active; @@ -168,7 +168,7 @@ int *countp; break; } if (sscanf(buf, "%d %s\n", &num, id) == 2) - save_uid(&queryctl->unseen, num, id); + save_uid(&queryctl->newsaved, num, id); } } } @@ -182,7 +182,7 @@ int socket; struct hostrec *queryctl; int num; { - if (!queryctl->saved) + if (!queryctl->oldsaved) return (num <= last); else { @@ -197,7 +197,7 @@ int num; char id[IDLEN+1]; if (sscanf(buf, "%*d %s", id) == 2) - return(uid_in_list(&queryctl->saved, id)); + return(uid_in_list(&queryctl->oldsaved, id)); else return(0); } @@ -37,29 +37,33 @@ * Here's the theory: * * At start of a query, we have a (possibly empty) list of UIDs to be - * considered `already seen'. These are messages that were left in + * considered seen in `oldsaved'. These are messages that were left in * the mailbox and *not deleted* on previous queries (we don't need to - * remember the UIDs of deleted messages because ... well, they're gone!). - * This list is set up by initialized_saved_list() from the .fetchids - * file and hangs off the host's `saved' member. + * remember the UIDs of deleted messages because ... well, they're gone!) + * This list is initially set up by initialized_saved_list() from the + * .fetchids file. * * Early in the query, during the execution of the protocol-specific - * getrange code, the driver expects that the host's `unseen' member + * getrange code, the driver expects that the host's `newsaved' member * will be filled with a list of UIDs and message numbers representing - * the unseen mailbox state. If this list is empty, the server did + * the mailbox state. If this list is empty, the server did * not respond to the request for a UID listing. * * Each time a message is fetched, we can check its UID against the - * `saved' list to see if it is old. If not, it should be downloaded + * `oldsaved' list to see if it is old. If not, it should be downloaded * (and possibly deleted). It should be downloaded anyway if --all * is on. It should not be deleted if --keep is on. * - * Each time a message is read, we remove its id from the `unseen' + * Each time a message is deleted, we remove its id from the `newsaved' * member. * - * At the end of the query, whatever remains in the `unseen' member - * (because it was not deleted) becomes the `saved' list. The old - * `saved' list is freed. + * At the end of the query, whatever remains in the `newsaved' member + * (because it was not deleted) becomes the `oldsaved' list. The old + * `oldsaved' list is freed. + * + * At the end of the fetchmail run, all current `oldsaved' lists are + * flushed out to the .fetchids file to be picked up by the next run. + * If there are no such messages, the file is deleted. */ /* UIDs associated with un-queried hosts */ @@ -76,7 +80,7 @@ char *idfile; /* make sure lists are initially empty */ for (hostp = hostlist; hostp; hostp = hostp->next) - hostp->saved = hostp->unseen = (struct idlist *)NULL; + hostp->oldsaved = hostp->newsaved = (struct idlist *)NULL; /* let's get stored message UIDs from previous queries */ if ((tmpfp = fopen(idfile, "r")) != (FILE *)NULL) { @@ -90,7 +94,7 @@ char *idfile; { if (strcmp(host, hostp->servername) == 0) { - save_uid(&hostp->saved, -1, id); + save_uid(&hostp->oldsaved, -1, id); break; } } @@ -170,11 +174,8 @@ void update_uid_lists(hostp) /* perform end-of-query actions on UID lists */ struct hostrec *hostp; { - /* - * Replace `saved' list with `unseen' list as modified by deletions. - */ - free_uid_list(&hostp->saved); - hostp->saved = hostp->unseen; + free_uid_list(&hostp->oldsaved); + hostp->oldsaved = hostp->newsaved; } void write_saved_lists(hostlist, idfile) @@ -190,7 +191,7 @@ char *idfile; /* if all lists are empty, nuke the file */ idcount = 0; for (hostp = hostlist; hostp; hostp = hostp->next) { - if (hostp->saved) + if (hostp->oldsaved) idcount++; } @@ -200,7 +201,7 @@ char *idfile; else if ((tmpfp = fopen(idfile, "w")) != (FILE *)NULL) { for (hostp = hostlist; hostp; hostp = hostp->next) { - for (idp = hostp->saved; idp; idp = idp->next) + for (idp = hostp->oldsaved; idp; idp = idp->next) fprintf(tmpfp, "%s %s\n", hostp->servername, idp->id); } for (idp = scratchlist; idp; idp = idp->next) |