Fixed bug #108: File updates sometimes produce duplicates.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 9 May 2005 19:57:35 +0000 (19:57 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 9 May 2005 19:57:35 +0000 (19:57 +0000)
index/dirs.c
index/index.h
index/trav.c

index df9768b..aa466a7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: dirs.c,v 1.22 2005-01-15 19:38:25 adam Exp $
+/* $Id: dirs.c,v 1.23 2005-05-09 19:57:35 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -101,7 +101,7 @@ struct dirs_info *dirs_open (Dict dict, const char *rep, int rw)
     return p;
 }
 
-struct dirs_info *dirs_fopen (Dict dict, const char *path)
+struct dirs_info *dirs_fopen (Dict dict, const char *path, int rw)
 {
     struct dirs_info *p;
     struct dirs_entry *entry;
@@ -109,6 +109,7 @@ struct dirs_info *dirs_fopen (Dict dict, const char *path)
 
     p = (struct dirs_info *) xmalloc (sizeof(*p));
     p->dict = dict;
+    p->rw = rw;
     *p->prefix = '\0';
     p->entries = (struct dirs_entry *) xmalloc (sizeof(*p->entries));
     p->no_read = 0;
index 5957bf6..d9ed54e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: index.h,v 1.136 2005-05-03 09:11:34 adam Exp $
+/* $Id: index.h,v 1.137 2005-05-09 19:57:35 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -78,7 +78,7 @@ struct dirs_entry {
 void getFnameTmp (Res res, char *fname, int no);
         
 struct dirs_info *dirs_open (Dict dict, const char *rep, int rw);
-struct dirs_info *dirs_fopen (Dict dict, const char *path);
+struct dirs_info *dirs_fopen (Dict dict, const char *path, int rw);
 struct dirs_entry *dirs_read (struct dirs_info *p);
 struct dirs_entry *dirs_last (struct dirs_info *p);
 void dirs_mkdir (struct dirs_info *p, const char *src, time_t mtime);
index 6ff7249..4d02b5e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: trav.c,v 1.47 2005-01-15 19:38:27 adam Exp $
+/* $Id: trav.c,v 1.48 2005-05-09 19:57:35 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -312,7 +312,7 @@ static void fileUpdate (ZebraHandle zh, Dict dict, const char *path)
     else if (S_ISREG(sbuf.st_mode))
     {
         struct dirs_entry *e_dst;
-        di = dirs_fopen (dict, src);
+        di = dirs_fopen (dict, src, zh->m_flag_rw);
 
         e_dst = dirs_read (di);
         if (e_dst)
@@ -392,6 +392,24 @@ static void repositoryExtractG (ZebraHandle zh, const char *path,
         repositoryExtract (zh, deleteFlag, path);
 }
 
+#if 0
+static int dump_file_dict_func(char *name, const char *info, int pos,
+                               void *client)
+{
+    yaz_log(YLOG_LOG, "%s", name);
+    return 0;
+}
+static void dump_file_dict(Dict dict)
+{
+    int before = 10;
+    int after = 1000;
+    char term[1000];
+    
+    strcpy(term, "0");
+    dict_scan (dict, term, &before, &after, 0, dump_file_dict_func);
+}
+#endif
+
 void repositoryUpdate (ZebraHandle zh, const char *path)
 {
     assert (path);
@@ -412,7 +430,11 @@ void repositoryUpdate (ZebraHandle zh, const char *path)
         }
         else
             fileUpdate (zh, dict, path);
+#if 0
+       dump_file_dict(dict);
+#endif
         dict_close (dict);
+       
     }
     else 
         repositoryExtractG (zh, path, 0);