mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
New function object_user_cache_del().
This commit is contained in:
parent
f403d6f8d3
commit
d00a01f32e
1 changed files with 21 additions and 4 deletions
25
data.c
25
data.c
|
@ -556,14 +556,28 @@ int object_admire(const char *id, const char *actor, int like)
|
|||
}
|
||||
|
||||
|
||||
int object_user_cache_add(snac *snac, const char *id, const char *cachedir)
|
||||
/* caches an object into a user cache */
|
||||
int _object_user_cache(snac *snac, const char *id, const char *cachedir, int del)
|
||||
/* adds or deletes from a user cache */
|
||||
{
|
||||
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));
|
||||
|
||||
return link(ofn, cfn);
|
||||
return del ? unlink(cfn) : link(ofn, cfn);
|
||||
}
|
||||
|
||||
|
||||
int object_user_cache_add(snac *snac, const char *id, const char *cachedir)
|
||||
/* caches an object into a user cache */
|
||||
{
|
||||
return _object_user_cache(snac, id, cachedir, 0);
|
||||
}
|
||||
|
||||
|
||||
int object_user_cache_del(snac *snac, const char *id, const char *cachedir)
|
||||
/* deletes an object from a user cache */
|
||||
{
|
||||
return _object_user_cache(snac, id, cachedir, 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -737,7 +751,10 @@ int timeline_del(snac *snac, char *id)
|
|||
ret = 200;
|
||||
}
|
||||
|
||||
object_del(id);
|
||||
if (valid_status(object_del(id))) {
|
||||
object_user_cache_del(snac, id, "public");
|
||||
object_user_cache_del(snac, id, "private");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue