mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-10 03:50:38 +03:00
New function object_del_if_unref().
This commit is contained in:
parent
832bbfd5eb
commit
9a0a03dd9f
18
data.c
18
data.c
@ -552,6 +552,20 @@ int object_del(const char *id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int object_del_if_unref(const char *id)
|
||||||
|
/* deletes an object if its n_links < 2 */
|
||||||
|
{
|
||||||
|
xs *fn = _object_fn(id);
|
||||||
|
int n_links;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if (mtime_nl(fn, &n_links) > 0.0 && n_links < 2)
|
||||||
|
ret = object_del(id);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
d_char *object_children(const char *id)
|
d_char *object_children(const char *id)
|
||||||
/* returns the list of an object's children */
|
/* returns the list of an object's children */
|
||||||
{
|
{
|
||||||
@ -791,8 +805,8 @@ int timeline_del(snac *snac, char *id)
|
|||||||
object_user_cache_del(snac, id, "public");
|
object_user_cache_del(snac, id, "public");
|
||||||
object_user_cache_del(snac, id, "private");
|
object_user_cache_del(snac, id, "private");
|
||||||
|
|
||||||
/* NOTE: this is a good place to count the # of links
|
/* try to delete the object if it's not used elsewhere */
|
||||||
of the object and object_del() it if it's < 2 */
|
object_del_if_unref(id);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
1
snac.h
1
snac.h
@ -60,6 +60,7 @@ d_char *index_list(const char *fn, int max);
|
|||||||
d_char *index_list_desc(const char *fn, int max);
|
d_char *index_list_desc(const char *fn, int max);
|
||||||
|
|
||||||
int object_del(const char *id);
|
int object_del(const char *id);
|
||||||
|
int object_del_if_unref(const char *id);
|
||||||
|
|
||||||
int follower_add(snac *snac, char *actor, char *msg);
|
int follower_add(snac *snac, char *actor, char *msg);
|
||||||
int follower_del(snac *snac, char *actor);
|
int follower_del(snac *snac, char *actor);
|
||||||
|
Loading…
Reference in New Issue
Block a user