commit 0f328d0

default  ·  2023-02-22 18:15:22 +0000 UTC
parent 4508630
New function index_unlock().
1 files changed,  +10, -2
M data.c
M data.c
+10, -2
 1@@ -254,6 +254,14 @@ FILE *index_lock(const char *fn)
 2 }
 3 
 4 
 5+void index_unlock(FILE *f, const char *fn)
 6+{
 7+    xs *lck = xs_fmt("%s.lck", fn);
 8+    unlink(lck);
 9+    fclose(f);
10+}
11+
12+
13 int index_add_md5(const char *fn, const char *md5)
14 /* adds an md5 to an index */
15 {
16@@ -275,7 +283,7 @@ int index_add_md5(const char *fn, const char *md5)
17     else
18         status = 500;
19 
20-    fclose(l);
21+    index_unlock(l, fn);
22 
23     return status;
24 }
25@@ -327,7 +335,7 @@ int index_del_md5(const char *fn, const char *md5)
26     else
27         status = 500;
28 
29-    fclose(l);
30+    index_unlock(l, fn);
31 
32     return status;
33 }