diff src/content.c @ 167:7ba337dafb2c noffle

[svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re: need to do a Cont_write on Lock_closeDatabases in case of unwritten content changes when releasing the lock. Update content to keep dirty flag and avoid unnecessary writes, and lock to signal server to re-read its group content info after the lock is released. Do NOT write content info on Lock_close if dirty, as the placeholder article in unsubscribed groups is currently done by adding it to the content when joining the group and deliberately not saving it unless another content modification takes place and thus causes the content to be saved.
author bears
date Sun, 25 Feb 2001 23:29:50 +0000
parents 988cacc01470
children fed1334d766b
line wrap: on
line diff
--- a/src/content.c	Sat Jan 27 09:57:13 2001 +0000
+++ b/src/content.c	Sun Feb 25 23:29:50 2001 +0000
@@ -1,7 +1,7 @@
 /*
   content.c
 
-  $Id: content.c 115 2000-05-19 15:18:05Z bears $
+  $Id: content.c 260 2001-02-25 23:29:50Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -38,7 +38,8 @@
                            in group. */
     Str name;
     Str file;
-} cont = { NULL, 1, 1, 0, 0, 0, NULL, "", "" };
+    Bool dirty;		/* Needs writing? */
+} cont = { NULL, 1, 1, 0, 0, 0, NULL, "", "", FALSE };
 
 void
 Cont_app( Over *ov )
@@ -59,6 +60,7 @@
         Ov_setNumb( ov, cont.vecFirst + cont.size );
     cont.elem[ cont.size++ ] = ov;
     cont.last = cont.vecFirst + cont.size - 1;
+    cont.dirty = TRUE;
 }
 
 Bool
@@ -78,6 +80,7 @@
     ov = &cont.elem[ n - cont.vecFirst ];
     free( *ov );
     *ov = NULL;
+    cont.dirty = TRUE;
 }
 
 /* Remove all overviews from content. */
@@ -186,6 +189,10 @@
     FILE *f;
     const Over *ov, *ov_next;
 
+    /* If nowt has changed, do nowt. */
+    if ( ! cont.dirty )
+	return;
+    
     /* Save the overview */
     if ( ! ( f = fopen( cont.file, "w" ) ) )
     {
@@ -241,6 +248,8 @@
 	unlink( cont.file );
 	cont.first = cont.last + 1;
     }
+
+    cont.dirty = FALSE;
 }
 
 const Over *