mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-09 19:50:26 +03:00
_object_user_cache() also update the indexes.
This commit is contained in:
parent
d00a01f32e
commit
8e83821eee
24
data.c
24
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 *ofn = _object_fn(id);
|
||||||
xs *l = xs_split(ofn, "/");
|
xs *l = xs_split(ofn, "/");
|
||||||
xs *cfn = xs_fmt("%s/%s/%s", snac->basedir, cachedir, xs_list_get(l, -1));
|
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)
|
void timeline_update_indexes(snac *snac, const char *id)
|
||||||
/* updates the indexes */
|
/* 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");
|
object_user_cache_add(snac, id, "private");
|
||||||
|
|
||||||
if (xs_startswith(id, snac->actor)) {
|
if (xs_startswith(id, snac->actor))
|
||||||
/* add to the public index */
|
|
||||||
idx = xs_replace_i(idx, "private", "public");
|
|
||||||
index_add(idx, id);
|
|
||||||
|
|
||||||
object_user_cache_add(snac, id, "public");
|
object_user_cache_add(snac, id, "public");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user