diff options
author | default <nobody@localhost> | 2022-11-25 17:26:12 +0100 |
---|---|---|
committer | default <nobody@localhost> | 2022-11-25 17:26:12 +0100 |
commit | 6c6b5a30c4570ac0ace13e95e28a678c3720b899 (patch) | |
tree | dc93af34c1877f60b6b762a053c7ed3db385dd47 | |
parent | 87d3ec2accb94c8a2f912a5ed7f8782f45f2151f (diff) |
Do hard links to objects in each user's public and private caches.
-rw-r--r-- | data.c | 17 | ||||
-rw-r--r-- | upgrade.c | 22 | ||||
-rw-r--r-- | utils.c | 3 |
3 files changed, 39 insertions, 3 deletions
@@ -14,7 +14,7 @@ #include <sys/file.h> #include <fcntl.h> -double db_layout = 2.3; +double db_layout = 2.4; int db_upgrade(d_char **error); @@ -901,12 +901,25 @@ void timeline_object_add(snac *snac, const char *id, char *msg) { object_add(id, msg); + /* add to the private index */ xs *idx = xs_fmt("%s/private.idx", snac->basedir); index_add(idx, id); + /* build the name for the linked copy in the private cache */ + xs *ofn = _object_fn(id); + xs *l = xs_split(ofn, "/"); + xs *cfn = xs_fmt("%s/private/%s", snac->basedir, xs_list_get(l, -1)); + + link(ofn, cfn); + if (xs_startswith(id, snac->actor)) { - idx = xs_replace_i(idx, "private.", "public."); + /* add to the public index */ + idx = xs_replace_i(idx, "private", "public"); index_add(idx, id); + + /* add to the public cache */ + cfn = xs_replace_i(cfn, "private", "public"); + link(ofn, cfn); } } @@ -106,6 +106,28 @@ int db_upgrade(d_char **error) nf = 2.3; } + else + if (f < 2.4) { + xs *users = user_list(); + char *p, *v; + + p = users; + while (xs_list_iter(&p, &v)) { + snac snac; + + if (user_open(&snac, v)) { + xs *dir = xs_fmt("%s/public", snac.basedir); + mkdir(dir, 0755); + + dir = xs_replace_i(dir, "public", "private"); + mkdir(dir, 0755); + + user_free(&snac); + } + } + + nf = 2.4; + } if (f < nf) { f = nf; @@ -238,7 +238,8 @@ int adduser(char *uid) const char *dirs[] = { "followers", "following", "local", "muted", "hidden", - "queue", "static", "timeline", "history", NULL }; + "public", "private", "queue", "history", + "static", "timeline", NULL }; int n; for (n = 0; dirs[n]; n++) { |