Fixed muted filenames.

This commit is contained in:
default 2022-11-24 10:06:24 +01:00
parent e121aeb948
commit 4494fc3daf
2 changed files with 14 additions and 1 deletions

2
data.c
View file

@ -1034,7 +1034,7 @@ d_char *following_list(snac *snac)
d_char *_muted_fn(snac *snac, char *actor)
{
xs *md5 = xs_md5_hex(actor, strlen(actor));
return xs_fmt("%s/muted/%s.json", snac->basedir, md5);
return xs_fmt("%s/muted/%s", snac->basedir, md5);
}

View file

@ -84,9 +84,22 @@ int db_upgrade(d_char **error)
snac snac;
if (user_open(&snac, v)) {
char *p, *v;
xs *dir = xs_fmt("%s/hidden", snac.basedir);
/* create the hidden directory */
mkdir(dir, 0755);
/* rename all muted files incorrectly named .json */
xs *spec = xs_fmt("%s/muted/" "*.json", snac.basedir);
xs *fns = xs_glob(spec, 0, 0);
p = fns;
while (xs_list_iter(&p, &v)) {
xs *nfn = xs_replace(v, ".json", "");
rename(v, nfn);
}
user_free(&snac);
}
}