commit b0b052a
default
·
2022-11-24 07:36:01 +0000 UTC
parent b23c6d9
Function object_del() also deletes the indexes.
1 files changed,
+17,
-2
M
data.c
M
data.c
+17,
-2
1@@ -424,10 +424,23 @@ int object_del(const char *id)
2 int status = 404;
3 xs *fn = _object_fn(id);
4
5- if (fn != NULL && unlink(fn) != -1)
6+ if (fn != NULL && unlink(fn) != -1) {
7 status = 200;
8
9- srv_debug(2, xs_fmt("object_del %s %d", id, status));
10+ /* also delete associated indexes */
11+ xs *spec = _object_fn(id);
12+ spec = xs_replace_i(spec, ".json", "*.idx");
13+ xs *files = xs_glob(spec, 0, 0);
14+ char *p, *v;
15+
16+ p = files;
17+ while (xs_list_iter(&p, &v)) {
18+ srv_debug(0, xs_fmt("object_del index %s", v));
19+ unlink(v);
20+ }
21+ }
22+
23+ srv_debug(0, xs_fmt("object_del %s %d", id, status));
24
25 return status;
26 }
27@@ -601,6 +614,8 @@ int timeline_del(snac *snac, char *id)
28 ret = 200;
29 }
30
31+ object_del(id);
32+
33 return ret;
34 }
35