New function: cf_unlink.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 11 Dec 1995 09:03:51 +0000 (09:03 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 11 Dec 1995 09:03:51 +0000 (09:03 +0000)
New member of commit file head: state (0) deleted, (1) hash file.

bfile/bfile.c
bfile/cfile.c
bfile/cfile.h
bfile/commit.c

index 85b01bb..2618fce 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: bfile.c,v $
- * Revision 1.16  1995-12-08 16:21:13  adam
+ * Revision 1.17  1995-12-11 09:03:51  adam
+ * New function: cf_unlink.
+ * New member of commit file head: state (0) deleted, (1) hash file.
+ *
+ * Revision 1.16  1995/12/08  16:21:13  adam
  * Work on commit/update.
  *
  * Revision 1.15  1995/12/01  16:24:28  adam
@@ -188,18 +192,27 @@ void bf_commitClean (void)
     char path[256];
     MFile mf;
     CFile cf;
+    int mustDisable = 0;
+    int firstTime;
+
+    if (!commit_area)
+    {
+        bf_cache (1);
+        mustDisable = 1;
+    }
 
-    assert (commit_area);
     if (!(inf = fopen ("cache", "r")))
         return ;
     while (fscanf (inf, "%s %d", path, &block_size) == 2)
     {
         mf = mf_open (0, path, block_size, 0);
-        cf = cf_open (mf, commit_area, path, block_size, 1, NULL);
-
+        cf = cf_open (mf, commit_area, path, block_size, 1, &firstTime);
+        cf_unlink (cf);
         cf_close (cf);
         mf_close (mf);
     }
     fclose (inf);
     unlink ("cache");
+    if (mustDisable)
+        bf_cache (0);
 }
index 284de86..fb8a96e 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: cfile.c,v $
- * Revision 1.5  1995-12-08 16:21:14  adam
+ * Revision 1.6  1995-12-11 09:03:53  adam
+ * New function: cf_unlink.
+ * New member of commit file head: state (0) deleted, (1) hash file.
+ *
+ * Revision 1.5  1995/12/08  16:21:14  adam
  * Work on commit/update.
  *
  * Revision 1.4  1995/12/01  16:24:28  adam
@@ -85,10 +89,12 @@ CFile cf_open (MFile mf, MFile_area area, const char *fname,
         logf (LOG_FATAL|LOG_ERRNO, "Failed to open %s", path);
         exit (1);
     }
-    if (!firstp || !mf_read (cf->hash_mf, 0, 0, sizeof(cf->head), &cf->head))
+    assert (firstp);
+    if (!mf_read (cf->hash_mf, 0, 0, sizeof(cf->head), &cf->head) ||
+        !cf->head.state)
     {
-        if (firstp)
-            *firstp = 1;
+        *firstp = 1;
+        cf->head.state = 1;
         cf->head.block_size = block_size;
         cf->head.hash_size = 401;
         hash_bytes = cf->head.hash_size * sizeof(int);
index 70ca0b3..07282ce 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: cfile.h,v $
- * Revision 1.3  1995-12-01 16:24:29  adam
+ * Revision 1.4  1995-12-11 09:03:54  adam
+ * New function: cf_unlink.
+ * New member of commit file head: state (0) deleted, (1) hash file.
+ *
+ * Revision 1.3  1995/12/01  16:24:29  adam
  * Commit files use separate meta file area.
  *
  * Revision 1.2  1995/12/01  11:37:23  adam
@@ -37,6 +41,7 @@ struct CFile_hash_bucket {
 typedef struct CFile_struct
 {
     struct CFile_head {
+        int state;
         int hash_size;
         int next_bucket;
         int next_block;
@@ -59,6 +64,7 @@ CFile cf_open (MFile mf, MFile_area area, const char *fname, int block_size,
                int wflag, int *firstp);
 int cf_read (CFile cf, int no, int offset, int num, void *buf);
 int cf_write (CFile cf, int no, int offset, int num, const void *buf);
+void cf_unlink (CFile cf);
 void cf_commit (CFile cf);
 
 #endif
index 777b7ae..e1b66e8 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: commit.c,v $
- * Revision 1.3  1995-12-01 16:24:29  adam
+ * Revision 1.4  1995-12-11 09:03:55  adam
+ * New function: cf_unlink.
+ * New member of commit file head: state (0) deleted, (1) hash file.
+ *
+ * Revision 1.3  1995/12/01  16:24:29  adam
  * Commit files use separate meta file area.
  *
  * Revision 1.2  1995/12/01  11:37:24  adam
 #include <mfile.h>
 #include "cfile.h"
 
+void cf_unlink (CFile cf)
+{
+    if (cf->bucket_in_memory)
+    {
+        logf (LOG_FATAL, "Cannot unlink potential dirty cache");
+        exit (1);
+    }
+    cf->head.state = 0;
+    cf->dirty = 1;
+}
+
 void cf_commit (CFile cf)
 {
     int i, bucket_no;