mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 17:45:04 +00:00
New db_layout 2.2.
This commit is contained in:
parent
01a62669f6
commit
5c05e60bce
2 changed files with 36 additions and 2 deletions
4
data.c
4
data.c
|
@ -14,7 +14,7 @@
|
|||
#include <sys/file.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
double db_layout = 2.1;
|
||||
double db_layout = 2.2;
|
||||
|
||||
|
||||
int db_upgrade(d_char **error);
|
||||
|
@ -195,7 +195,7 @@ double mtime(char *fn)
|
|||
|
||||
d_char *_object_fn_by_md5(const char *md5)
|
||||
{
|
||||
xs *bfn = xs_fmt("%s/object/%c%c/", srv_basedir, md5[0], md5[1]);
|
||||
xs *bfn = xs_fmt("%s/object/%c%c", srv_basedir, md5[0], md5[1]);
|
||||
|
||||
mkdir(bfn, 0755);
|
||||
|
||||
|
|
34
upgrade.c
34
upgrade.c
|
@ -40,6 +40,40 @@ int db_upgrade(d_char **error)
|
|||
|
||||
nf = 2.1;
|
||||
}
|
||||
else
|
||||
if (f < 2.2) {
|
||||
xs *users = user_list();
|
||||
char *p, *v;
|
||||
|
||||
p = users;
|
||||
while (xs_list_iter(&p, &v)) {
|
||||
snac snac;
|
||||
|
||||
if (user_open(&snac, v)) {
|
||||
xs *spec = xs_fmt("%s/actors/" "*.json", snac.basedir);
|
||||
xs *list = xs_glob(spec, 0, 0);
|
||||
char *g, *fn;
|
||||
|
||||
g = list;
|
||||
while (xs_list_iter(&g, &fn)) {
|
||||
xs *l = xs_split(fn, "/");
|
||||
char *b = xs_list_get(l, -1);
|
||||
xs *dir = xs_fmt("%s/object/%c%c", srv_basedir, b[0], b[1]);
|
||||
xs *nfn = xs_fmt("%s/%s", dir, b);
|
||||
|
||||
mkdir(dir, 0755);
|
||||
rename(fn, nfn);
|
||||
}
|
||||
|
||||
xs *odir = xs_fmt("%s/actors", snac.basedir);
|
||||
rmdir(odir);
|
||||
|
||||
user_free(&snac);
|
||||
}
|
||||
}
|
||||
|
||||
nf = 2.2;
|
||||
}
|
||||
|
||||
if (f < nf) {
|
||||
f = nf;
|
||||
|
|
Loading…
Reference in a new issue