[tin 1.7.x] newsgroups-file caching fix
Urs Janßen <[email protected]>
| Newsgroups | gmane.network.tin.devel |
|---|---|
| Message-ID | <[email protected]> |
the attached patch over yesterdays snapshot fixes the logic behind the newsgroups-file caching (no big win except for the '-q' case). urs -- "Only whimps use tape backup: _real_ men just upload their important stuff on ftp, and let the rest of the world mirror it ;)" - Linus
tin-1.7.10.snaptotin-1.7.10.diff
(text/plain, 4.7 KB)
diff -Nurp tin-1.7.10.snap/doc/tin.1 tin-1.7.10/doc/tin.1
--- tin-1.7.10.snap/doc/tin.1 2005-08-15 11:43:45.000000000 +0200
+++ tin-1.7.10/doc/tin.1 2005-09-14 14:36:31.200463226 +0200
@@ -2852,6 +2852,9 @@ For a detailed description see
.IR ${TIN_HOMEDIR\-"$HOME"}/.tin/postponed.articles
.PP
+.IR ${TIN_HOMEDIR\-"$HOME"}/.tin/$NNTPSERVER:${NNTPPORT+":$NNTPPORT"}/newsgroups
+.PP
+
.IR ${TIN_HOMEDIR\-"$HOME"}/.tin/$NNTPSERVER:${NNTPPORT+":$NNTPPORT"}/serverrc
.PP
diff -Nurp tin-1.7.10.snap/doc/tin.5 tin-1.7.10/doc/tin.5
--- tin-1.7.10.snap/doc/tin.5 2005-08-07 13:58:37.000000000 +0200
+++ tin-1.7.10/doc/tin.5 2005-09-14 14:34:57.670787215 +0200
@@ -340,7 +340,7 @@ mailgroups index files
.RE
.PP
-.IR ${TIN_INDEX_NEWSDIRÃ-"${TIN_HOMEDIR\-"$HOME"}/.tin"}/.news${NNTPSERVER+"\-$NNTPSERVER"}/
+.IR ${TIN_INDEX_NEWSDIR\-"${TIN_HOMEDIR\-"$HOME"}/.tin"}/.news${NNTPSERVER+"\-$NNTPSERVER"}/
.sp
.RS
newsgroups index files
@@ -995,6 +995,23 @@ format.
.RE
.PP
+.IR ${TIN_HOMEDIR\-"$HOME"}/.tin/$NNTPSERVER${NNTPPORT+":$NNTPPORT"}/newsgroups
+.sp
+.RS
+This file a copy of the servers newsgroups file which provides short
+descriptions of each newsgroup. It is automatically updated on startup
+except when using the ''\fB\-q\fP'' command-line option. Each line consist
+of two tab-separated fields "\fIgroup.name\fR \fIone-line description\fR".
+.TP
+.B group.name
+is the name of the newsgroup
+.TP
+.B one-line description
+is a short single-line description of the group
+.RE
+.PP
+
+
.IR ${TIN_HOMEDIR\-"$HOME"}/.tin/$NNTPSERVER${NNTPPORT+":$NNTPPORT"}/serverrc
.sp
.RS
diff -Nurp tin-1.7.10.snap/src/config.c tin-1.7.10/src/config.c
--- tin-1.7.10.snap/src/config.c 2005-06-28 10:31:24.000000000 +0200
+++ tin-1.7.10/src/config.c 2005-09-14 14:09:09.245886877 +0200
@@ -1833,7 +1833,7 @@ read_server_config(
}
JOINPATH(serverdir, rcdir, file);
joinpath(file, serverdir, SERVERCONFIG_FILE);
-
+ joinpath(local_newsgroups_file, serverdir, NEWSGROUPS_FILE);
if ((fp = fopen(file, "r")) == NULL)
return;
while (NULL != (line = tin_fgets(fp, FALSE))) {
diff -Nurp tin-1.7.10.snap/src/init.c tin-1.7.10/src/init.c
--- tin-1.7.10.snap/src/init.c 2005-07-21 15:17:48.000000000 +0200
+++ tin-1.7.10/src/init.c 2005-09-14 14:16:15.546923967 +0200
@@ -811,7 +811,6 @@ init_selfinfo(
joinpath(filter_file, rcdir, FILTER_FILE);
joinpath(local_input_history_file, rcdir, INPUT_HISTORY_FILE);
joinpath(local_newsrctable_file, rcdir, NEWSRCTABLE_FILE);
- joinpath(local_newsgroups_file, rcdir, NEWSGROUPS_FILE);
#ifdef HAVE_MH_MAIL_HANDLING
joinpath(mail_active_file, rcdir, ACTIVE_MAIL_FILE);
#endif /* HAVE_MH_MAIL_HANDLING */
diff -Nurp tin-1.7.10.snap/src/mail.c tin-1.7.10/src/mail.c
--- 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;
}
diff -Nurp tin-1.7.10.snap/src/main.c tin-1.7.10/src/main.c
--- tin-1.7.10.snap/src/main.c 2005-07-17 15:30:02.000000000 +0200
+++ tin-1.7.10/src/main.c 2005-09-14 14:17:20.378917131 +0200
@@ -288,8 +288,11 @@ main(
/*
* Read text descriptions for mail and/or news groups
*/
- if (show_description && !batch_mode)
+ if (show_description && !batch_mode) {
+ no_write = tmp_no_write; /* restore original value */
read_descriptions(TRUE);
+ no_write = TRUE; /* disable newsrc updates */
+ }
/*
* TODO: what has write_config_file() to do with create_mail_save_dirs ()
diff -Nurp tin-1.7.10.snap/src/misc.c tin-1.7.10/src/misc.c
--- tin-1.7.10.snap/src/misc.c 2005-08-19 21:25:52.000000000 +0200
+++ tin-1.7.10/src/misc.c 2005-09-14 14:23:09.950056000 +0200
@@ -2059,8 +2059,15 @@ cleanup_tmp_files(
}
#endif /* 0 */
+/*
+ * as we now keep a newsgroups file per server and we update it on every
+ * start except when using the -q -cmd-line option there is no need to
+ * unlik it on exit. the cache_overview_files logic was a bit hairy anyway.
+ */
+#if 0
if (!tinrc.cache_overview_files)
unlink(local_newsgroups_file);
+#endif /* 0 */
if (batch_mode)
unlink(lock_file);