mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-09 19:50:26 +03:00
Do hard links to objects in each user's public and private caches.
This commit is contained in:
parent
87d3ec2acc
commit
6c6b5a30c4
17
data.c
17
data.c
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
22
upgrade.c
22
upgrade.c
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user