commit 8e83821eeec1fb967afb4b26896271c6106c25ef
parent d00a01f32e166389bbf8383dc606107208b3642b
Author: default <nobody@localhost>
Date: Sat, 26 Nov 2022 05:58:13 +0100
_object_user_cache() also update the indexes.
Diffstat:
M | data.c | | | 24 | +++++++++++++----------- |
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/data.c b/data.c
@@ -562,8 +562,19 @@ int _object_user_cache(snac *snac, const char *id, const char *cachedir, int del
xs *ofn = _object_fn(id);
xs *l = xs_split(ofn, "/");
xs *cfn = xs_fmt("%s/%s/%s", snac->basedir, cachedir, xs_list_get(l, -1));
+ xs *idx = xs_fmt("%s/%s.idx", snac->basedir, cachedir);
+ int ret;
- return del ? unlink(cfn) : link(ofn, cfn);
+ if (del) {
+ index_del(idx, id);
+ ret = unlink(cfn);
+ }
+ else {
+ index_add(idx, id);
+ ret = link(ofn, cfn);
+ }
+
+ return ret;
}
@@ -959,19 +970,10 @@ int _timeline_write(snac *snac, char *id, char *msg, char *parent, char *referre
void timeline_update_indexes(snac *snac, const char *id)
/* updates the indexes */
{
- /* add to the private index */
- xs *idx = xs_fmt("%s/private.idx", snac->basedir);
- index_add(idx, id);
-
object_user_cache_add(snac, id, "private");
- if (xs_startswith(id, snac->actor)) {
- /* add to the public index */
- idx = xs_replace_i(idx, "private", "public");
- index_add(idx, id);
-
+ if (xs_startswith(id, snac->actor))
object_user_cache_add(snac, id, "public");
- }
}