commit 8e83821
default
·
2022-11-26 04:58:13 +0000 UTC
parent d00a01f
_object_user_cache() also update the indexes.
1 files changed,
+13,
-11
M
data.c
M
data.c
+13,
-11
1@@ -562,8 +562,19 @@ int _object_user_cache(snac *snac, const char *id, const char *cachedir, int del
2 xs *ofn = _object_fn(id);
3 xs *l = xs_split(ofn, "/");
4 xs *cfn = xs_fmt("%s/%s/%s", snac->basedir, cachedir, xs_list_get(l, -1));
5+ xs *idx = xs_fmt("%s/%s.idx", snac->basedir, cachedir);
6+ int ret;
7
8- return del ? unlink(cfn) : link(ofn, cfn);
9+ if (del) {
10+ index_del(idx, id);
11+ ret = unlink(cfn);
12+ }
13+ else {
14+ index_add(idx, id);
15+ ret = link(ofn, cfn);
16+ }
17+
18+ return ret;
19 }
20
21
22@@ -959,19 +970,10 @@ int _timeline_write(snac *snac, char *id, char *msg, char *parent, char *referre
23 void timeline_update_indexes(snac *snac, const char *id)
24 /* updates the indexes */
25 {
26- /* add to the private index */
27- xs *idx = xs_fmt("%s/private.idx", snac->basedir);
28- index_add(idx, id);
29-
30 object_user_cache_add(snac, id, "private");
31
32- if (xs_startswith(id, snac->actor)) {
33- /* add to the public index */
34- idx = xs_replace_i(idx, "private", "public");
35- index_add(idx, id);
36-
37+ if (xs_startswith(id, snac->actor))
38 object_user_cache_add(snac, id, "public");
39- }
40 }
41
42