diff options
| -rw-r--r-- | data.c | 27 |
1 files changed, 19 insertions, 8 deletions
| @@ -13,7 +13,7 @@ | |||
| 13 | #include <glob.h> | 13 | #include <glob.h> |
| 14 | #include <sys/stat.h> | 14 | #include <sys/stat.h> |
| 15 | 15 | ||
| 16 | double db_layout = 2.0; | 16 | double db_layout = 2.1; |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | int db_upgrade(d_char **error); | 19 | int db_upgrade(d_char **error); |
| @@ -1246,25 +1246,34 @@ int db_upgrade(d_char **error) | |||
| 1246 | 1246 | ||
| 1247 | do { | 1247 | do { |
| 1248 | char *layout = xs_dict_get(srv_config, "layout"); | 1248 | char *layout = xs_dict_get(srv_config, "layout"); |
| 1249 | double nf; | ||
| 1249 | 1250 | ||
| 1250 | f = xs_number_get(layout); | 1251 | f = nf = xs_number_get(layout); |
| 1251 | 1252 | ||
| 1252 | if (f < 2.0) { | 1253 | if (f < 2.0) { |
| 1253 | *error = xs_fmt("ERROR: unsupported old disk layout %lf\n", f); | 1254 | *error = xs_fmt("ERROR: unsupported old disk layout %1.1lf\n", f); |
| 1254 | ret = 0; | 1255 | ret = 0; |
| 1255 | break; | 1256 | break; |
| 1256 | } | 1257 | } |
| 1257 | /* else | 1258 | else |
| 1258 | if (f < 2.1) { | 1259 | if (f < 2.1) { |
| 1259 | srv_log(xs_dup("upgrading db layout to version 2.1")); | ||
| 1260 | |||
| 1261 | xs *dir = xs_fmt("%s/object", srv_basedir); | 1260 | xs *dir = xs_fmt("%s/object", srv_basedir); |
| 1262 | mkdir(dir, 0755); | 1261 | mkdir(dir, 0755); |
| 1263 | 1262 | ||
| 1264 | xs *nv = xs_number_new(2.1); | 1263 | nf = 2.1; |
| 1264 | } | ||
| 1265 | |||
| 1266 | if (f < nf) { | ||
| 1267 | f = nf; | ||
| 1268 | xs *nv = xs_number_new(f); | ||
| 1265 | srv_config = xs_dict_set(srv_config, "layout", nv); | 1269 | srv_config = xs_dict_set(srv_config, "layout", nv); |
| 1270 | |||
| 1271 | srv_log(xs_fmt("upgraded db layout to version %1.1lf", f)); | ||
| 1266 | changed++; | 1272 | changed++; |
| 1267 | }*/ | 1273 | } |
| 1274 | else | ||
| 1275 | break; | ||
| 1276 | |||
| 1268 | } while (f < db_layout); | 1277 | } while (f < db_layout); |
| 1269 | 1278 | ||
| 1270 | if (f > db_layout) { | 1279 | if (f > db_layout) { |
| @@ -1281,6 +1290,8 @@ int db_upgrade(d_char **error) | |||
| 1281 | xs *j = xs_json_dumps_pp(srv_config, 4); | 1290 | xs *j = xs_json_dumps_pp(srv_config, 4); |
| 1282 | fwrite(j, strlen(j), 1, f); | 1291 | fwrite(j, strlen(j), 1, f); |
| 1283 | fclose(f); | 1292 | fclose(f); |
| 1293 | |||
| 1294 | srv_log(xs_fmt("upgraded db %s after %d changes", fn, changed)); | ||
| 1284 | } | 1295 | } |
| 1285 | else | 1296 | else |
| 1286 | ret = 0; | 1297 | ret = 0; |