Re: [tin 1.7.x] newsgroups-file caching fix
Urs Janßen <[email protected]>
| Newsgroups | gmane.network.tin.devel |
|---|---|
| Organization | tin.org |
| Message-ID | <[email protected]> |
In <[email protected]>, Urs Janßen wrote: > --- tin-1.7.10.snap/src/mail.c 2005-06-28 10:31:21.000000000 +0200 > +++ tin-1.7.10/src/mail.c 2005-09-14 14:44:57.118771222 +0200 > @@ -252,12 +252,18 @@ open_newsgroups_fp( > > if (read_news_via_nntp && !read_saved_news) { > if (read_local_newsgroups_file) { > - result = fopen(local_newsgroups_file, "r"); > - if (result != NULL) { > + struct stat buf; > + > + if (!stat(local_newsgroups_file, &buf)) { > + if (buf.st_size > 0) { > + if ((result = fopen(local_newsgroups_file, "r")) != NULL) { > # ifdef DEBUG > - debug_nntp("open_newsgroups_fp", "Using local copy of newsgroups file"); > + debug_nntp("open_newsgroups_fp", "Using local copy of newsgroups file"); > # endif /* DEBUG */ > - return result; > + return result; > + } > + } else > + unlink(local_newsgroups_file); > } > read_local_newsgroups_file = FALSE; > } the read_local_newsgroups_file = FALSE; isn't needed anymore and should be removed for maximum efficiency.