commit 5a5835b
default
·
2023-02-22 20:52:24 +0000 UTC
parent 0f328d0
Deleted the index_lock() nonsense.
1 files changed,
+2,
-30
M
data.c
M
data.c
+2,
-30
1@@ -244,32 +244,11 @@ double mtime_nl(const char *fn, int *n_link)
2 /** indexes **/
3
4
5-FILE *index_lock(const char *fn)
6-{
7- xs *lck = xs_fmt("%s.lck", fn);
8- FILE *f = fopen(lck, "a");
9- flock(fileno(f), LOCK_EX);
10-
11- return f;
12-}
13-
14-
15-void index_unlock(FILE *f, const char *fn)
16-{
17- xs *lck = xs_fmt("%s.lck", fn);
18- unlink(lck);
19- fclose(f);
20-}
21-
22-
23 int index_add_md5(const char *fn, const char *md5)
24 /* adds an md5 to an index */
25 {
26 int status = 201; /* Created */
27- FILE *l, *f;
28-
29- if ((l = index_lock(fn)) == NULL)
30- return 500;
31+ FILE *f;
32
33 if ((f = fopen(fn, "a")) != NULL) {
34 flock(fileno(f), LOCK_EX);
35@@ -283,8 +262,6 @@ int index_add_md5(const char *fn, const char *md5)
36 else
37 status = 500;
38
39- index_unlock(l, fn);
40-
41 return status;
42 }
43
44@@ -301,10 +278,7 @@ int index_del_md5(const char *fn, const char *md5)
45 /* deletes an md5 from an index */
46 {
47 int status = 404;
48- FILE *l, *i, *o;
49-
50- if ((l = index_lock(fn)) == NULL)
51- return 500;
52+ FILE *i, *o;
53
54 if ((i = fopen(fn, "r")) != NULL) {
55 flock(fileno(i), LOCK_EX);
56@@ -335,8 +309,6 @@ int index_del_md5(const char *fn, const char *md5)
57 else
58 status = 500;
59
60- index_unlock(l, fn);
61-
62 return status;
63 }
64