commit 3ff7e62

default  ·  2024-08-29 04:47:55 +0000 UTC
parent a22dfef
Adding to and object cache always create the cache directory.
1 files changed,  +5, -13
M data.c
M data.c
+5, -13
 1@@ -1033,6 +1033,10 @@ int _object_user_cache(snac *user, const char *id, const char *cachedir, int del
 2         index_del(idx, id);
 3     }
 4     else {
 5+        /* create the subfolder, if it does not exist */
 6+        xs *dir = xs_fmt("%s/%s/", user->basedir, cachedir);
 7+        mkdirx(dir);
 8+
 9         if ((ret = link(ofn, cfn)) != -1)
10             index_add(idx, id);
11     }
12@@ -1541,18 +1545,10 @@ int is_muted(snac *snac, const char *actor)
13 
14 /** bookmarking **/
15 
16-xs_str *_bookmark_fn(snac *user, const char *id)
17-{
18-    xs *md5 = xs_md5_hex(id, strlen(id));
19-    return xs_fmt("%s/bookmark/%s.json", user->basedir, md5);
20-}
21-
22-
23 int is_bookmarked(snac *user, const char *id)
24 /* returns true if this note is bookmarked */
25 {
26-    xs *fn = _bookmark_fn(user, id);
27-    return !!(mtime(fn) != 0.0);
28+    return object_user_cache_in(user, "bookmark", id);
29 }
30 
31 
32@@ -1562,10 +1558,6 @@ int bookmark(snac *user, const char *id)
33     if (is_bookmarked(user, id))
34         return -3;
35 
36-    /* create the subfolder, if it does not exist */
37-    xs *fn = xs_fmt("%s/bookmark/", user->basedir);
38-    mkdirx(fn);
39-
40     return object_user_cache_add(user, id, "bookmark");
41 }
42