changeset 218:411b6ab1acb7 noffle

[svn] *src/content.c,src/noffle.c: Correct bugfix in Conf_write(). Remove temporary file expiry, but skip temp files in Cont_nextGrp().
author bears
date Thu, 22 Nov 2001 22:48:07 +0000
parents b4f1731a6470
children d9f314014f7a
files ChangeLog src/content.c src/noffle.c
diffstat 3 files changed, 39 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Nov 22 22:25:12 2001 +0000
+++ b/ChangeLog	Thu Nov 22 22:48:07 2001 +0000
@@ -3,7 +3,10 @@
 * Makefile.in,aclocal.m4,config.h.in,configure,configure.in
   docs/Makefile.in,src/Makefile.in: Regularise format of Noffle
   default parameters in configure.in and regenerate.
-
+*src/content.c,src/noffle.c: Correct bugfix in Conf_write().
+  Remove temporary file expiry, but skip temp files in
+  Cont_nextGrp().
+	
 Thu Nov 22 2001 Mirko Liß <mirko.liss@web.de>
 
 * src/noffle.c: expireContents() expires overview temporary files.
--- a/src/content.c	Thu Nov 22 22:25:12 2001 +0000
+++ b/src/content.c	Thu Nov 22 22:48:07 2001 +0000
@@ -1,7 +1,7 @@
 /*
   content.c
 
-  $Id: content.c 332 2001-11-22 12:05:11Z mirkol $
+  $Id: content.c 337 2001-11-22 22:48:07Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -263,6 +263,8 @@
     {
 	if ( unlink( tmpfname ) < 0 )
 	    Log_err( "Unlink of %s failed: %s", tmpfname, strerror( errno ) );
+	if ( unlink( cont.file ) < 0 )
+	    Log_err( "Unlink of %s failed: %s", cont.file, strerror( errno ) );
 	else
 	{
 	    cont.dirty = FALSE;
@@ -325,6 +327,36 @@
     }
     if ( ! d->d_name )
         return FALSE;
+    if ( d->d_name[0] == '.' )
+    {
+	/*
+	 * If it is '.' or '..', skip.
+	 * If it starts '.#', treat as a temporary file that didn't
+	 * get deleted for some reason and flag an error.
+	 * Otherwise weirdness lurks; log an error.
+	 *
+	 * N.B. Don't delete it! I'm not sure what happens to
+	 * readdir if you go around deleting stuff from the directory
+	 * between calls. The Single Unix Spec v2 isn't either.
+	 */
+	switch( d->d_name[1] )
+	{
+	case '\0':
+	case '.':
+	    break;
+
+	case '#':
+	    Log_err( "Bad temporary file %s in %s/overview - please delete",
+		     d->d_name, Cfg_spoolDir() );
+	    break;
+
+	default:
+	    Log_err( "Unknown file %s in %s/overview - please delete",
+		     d->d_name, Cfg_spoolDir() );
+	    break;
+	}
+	return Cont_nextGrp( result );
+    }
     Utl_cpyStr( result, d->d_name );
     result[ MAXCHAR - 1 ] = '\0';
     return TRUE;
@@ -341,7 +373,5 @@
         Log_err( "Cannot open %s", name );
         return FALSE;
     }
-    Cont_nextGrp( result ); /* "."  */
-    Cont_nextGrp( result ); /* ".." */
     return Cont_nextGrp( result );
 }
--- a/src/noffle.c	Thu Nov 22 22:25:12 2001 +0000
+++ b/src/noffle.c	Thu Nov 22 22:48:07 2001 +0000
@@ -10,7 +10,7 @@
   received for some seconds (to allow multiple clients connect at the same
   time).
 
-  $Id: noffle.c 333 2001-11-22 12:05:40Z mirkol $
+  $Id: noffle.c 337 2001-11-22 22:48:07Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -241,7 +241,6 @@
     int i;
     int cntDel, cntLeft;
     Str grp;
-    Str tmpfname;
     Bool autoUnsubscribe;
     int autoUnsubscribeDays;
     time_t maxAge = 0;
@@ -256,18 +255,7 @@
     Fetchlist_read();
     do
     {
-        /* delete tmpfnames. see content.c:Cont_write() */
-        if ( Wld_match(grp, ".#[0123456789][0123456789]*.*" ) )
-        {
-            if ( ( snprintf( tmpfname, MAXCHAR, "%s/overview/%s", \
-              Cfg_spoolDir(), grp ) < 0 ) \
-              || ( unlink( tmpfname ) < 0 ) )
-                Log_err( "Unlink of overview temp file %s failed: %s", \
-                  grp, strerror( errno ) );
-            else
-                Log_err( "Overview temp file %s deleted.", grp );
-        }
-        else if ( ! Grp_exists( grp ) )
+	if ( ! Grp_exists( grp ) )
             Log_err( "Overview file for unknown group %s exists", grp );
         else
         {