diff options
| -rw-r--r-- | data.c | 4 | ||||
| -rw-r--r-- | upgrade.c | 34 |
2 files changed, 36 insertions, 2 deletions
| @@ -14,7 +14,7 @@ | |||
| 14 | #include <sys/file.h> | 14 | #include <sys/file.h> |
| 15 | #include <fcntl.h> | 15 | #include <fcntl.h> |
| 16 | 16 | ||
| 17 | double db_layout = 2.1; | 17 | double db_layout = 2.2; |
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | int db_upgrade(d_char **error); | 20 | int db_upgrade(d_char **error); |
| @@ -195,7 +195,7 @@ double mtime(char *fn) | |||
| 195 | 195 | ||
| 196 | d_char *_object_fn_by_md5(const char *md5) | 196 | d_char *_object_fn_by_md5(const char *md5) |
| 197 | { | 197 | { |
| 198 | xs *bfn = xs_fmt("%s/object/%c%c/", srv_basedir, md5[0], md5[1]); | 198 | xs *bfn = xs_fmt("%s/object/%c%c", srv_basedir, md5[0], md5[1]); |
| 199 | 199 | ||
| 200 | mkdir(bfn, 0755); | 200 | mkdir(bfn, 0755); |
| 201 | 201 | ||
| @@ -40,6 +40,40 @@ int db_upgrade(d_char **error) | |||
| 40 | 40 | ||
| 41 | nf = 2.1; | 41 | nf = 2.1; |
| 42 | } | 42 | } |
| 43 | else | ||
| 44 | if (f < 2.2) { | ||
| 45 | xs *users = user_list(); | ||
| 46 | char *p, *v; | ||
| 47 | |||
| 48 | p = users; | ||
| 49 | while (xs_list_iter(&p, &v)) { | ||
| 50 | snac snac; | ||
| 51 | |||
| 52 | if (user_open(&snac, v)) { | ||
| 53 | xs *spec = xs_fmt("%s/actors/" "*.json", snac.basedir); | ||
| 54 | xs *list = xs_glob(spec, 0, 0); | ||
| 55 | char *g, *fn; | ||
| 56 | |||
| 57 | g = list; | ||
| 58 | while (xs_list_iter(&g, &fn)) { | ||
| 59 | xs *l = xs_split(fn, "/"); | ||
| 60 | char *b = xs_list_get(l, -1); | ||
| 61 | xs *dir = xs_fmt("%s/object/%c%c", srv_basedir, b[0], b[1]); | ||
| 62 | xs *nfn = xs_fmt("%s/%s", dir, b); | ||
| 63 | |||
| 64 | mkdir(dir, 0755); | ||
| 65 | rename(fn, nfn); | ||
| 66 | } | ||
| 67 | |||
| 68 | xs *odir = xs_fmt("%s/actors", snac.basedir); | ||
| 69 | rmdir(odir); | ||
| 70 | |||
| 71 | user_free(&snac); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | nf = 2.2; | ||
| 76 | } | ||
| 43 | 77 | ||
| 44 | if (f < nf) { | 78 | if (f < nf) { |
| 45 | f = nf; | 79 | f = nf; |