summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
Diffstat (limited to 'data.c')
-rw-r--r--data.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/data.c b/data.c
index f780de2..b6fdc7a 100644
--- a/data.c
+++ b/data.c
@@ -552,6 +552,20 @@ int object_del(const char *id)
552} 552}
553 553
554 554
555int object_del_if_unref(const char *id)
556/* deletes an object if its n_links < 2 */
557{
558 xs *fn = _object_fn(id);
559 int n_links;
560 int ret = 0;
561
562 if (mtime_nl(fn, &n_links) > 0.0 && n_links < 2)
563 ret = object_del(id);
564
565 return ret;
566}
567
568
555d_char *object_children(const char *id) 569d_char *object_children(const char *id)
556/* returns the list of an object's children */ 570/* returns the list of an object's children */
557{ 571{
@@ -791,8 +805,8 @@ int timeline_del(snac *snac, char *id)
791 object_user_cache_del(snac, id, "public"); 805 object_user_cache_del(snac, id, "public");
792 object_user_cache_del(snac, id, "private"); 806 object_user_cache_del(snac, id, "private");
793 807
794 /* NOTE: this is a good place to count the # of links 808 /* try to delete the object if it's not used elsewhere */
795 of the object and object_del() it if it's < 2 */ 809 object_del_if_unref(id);
796 810
797 return ret; 811 return ret;
798} 812}