mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 22:45:05 +00:00
Some symbol renaming.
This commit is contained in:
parent
2d7074aeb0
commit
74d30a561c
4 changed files with 12 additions and 12 deletions
8
data.c
8
data.c
|
@ -15,10 +15,10 @@
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
double db_layout = 2.7;
|
double disk_layout = 2.7;
|
||||||
|
|
||||||
|
|
||||||
int db_upgrade(d_char **error);
|
int snac_upgrade(d_char **error);
|
||||||
|
|
||||||
int srv_open(char *basedir, int auto_upgrade)
|
int srv_open(char *basedir, int auto_upgrade)
|
||||||
/* opens a server */
|
/* opens a server */
|
||||||
|
@ -71,9 +71,9 @@ int srv_open(char *basedir, int auto_upgrade)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto_upgrade)
|
if (auto_upgrade)
|
||||||
ret = db_upgrade(&error);
|
ret = snac_upgrade(&error);
|
||||||
else {
|
else {
|
||||||
if (xs_number_get(xs_dict_get(srv_config, "layout")) < db_layout)
|
if (xs_number_get(xs_dict_get(srv_config, "layout")) < disk_layout)
|
||||||
error = xs_fmt("ERROR: disk layout changed - execute 'snac upgrade' first");
|
error = xs_fmt("ERROR: disk layout changed - execute 'snac upgrade' first");
|
||||||
else
|
else
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
2
snac.h
2
snac.h
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#define USER_AGENT "snac/" VERSION
|
#define USER_AGENT "snac/" VERSION
|
||||||
|
|
||||||
extern double db_layout;
|
extern double disk_layout;
|
||||||
extern d_char *srv_basedir;
|
extern d_char *srv_basedir;
|
||||||
extern d_char *srv_config;
|
extern d_char *srv_config;
|
||||||
extern d_char *srv_baseurl;
|
extern d_char *srv_baseurl;
|
||||||
|
|
12
upgrade.c
12
upgrade.c
|
@ -11,7 +11,7 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
|
||||||
int db_upgrade(d_char **error)
|
int snac_upgrade(xs_str **error)
|
||||||
{
|
{
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
|
@ -23,10 +23,10 @@ int db_upgrade(d_char **error)
|
||||||
|
|
||||||
f = nf = xs_number_get(layout);
|
f = nf = xs_number_get(layout);
|
||||||
|
|
||||||
if (!(f < db_layout))
|
if (!(f < disk_layout))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
srv_log(xs_fmt("db_upgrade %1.1lf < %1.1lf", f, db_layout));
|
srv_log(xs_fmt("disk layout upgrade needed (%1.1lf < %1.1lf)", f, disk_layout));
|
||||||
|
|
||||||
if (f < 2.0) {
|
if (f < 2.0) {
|
||||||
*error = xs_fmt("ERROR: unsupported old disk layout %1.1lf\n", f);
|
*error = xs_fmt("ERROR: unsupported old disk layout %1.1lf\n", f);
|
||||||
|
@ -294,14 +294,14 @@ int db_upgrade(d_char **error)
|
||||||
xs *nv = xs_number_new(f);
|
xs *nv = xs_number_new(f);
|
||||||
srv_config = xs_dict_set(srv_config, "layout", nv);
|
srv_config = xs_dict_set(srv_config, "layout", nv);
|
||||||
|
|
||||||
srv_log(xs_fmt("db_upgrade converted to version %1.1lf", f));
|
srv_log(xs_fmt("disk layout upgraded to version %1.1lf", f));
|
||||||
changed++;
|
changed++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f > db_layout) {
|
if (f > disk_layout) {
|
||||||
*error = xs_fmt("ERROR: unknown future version %lf\n", f);
|
*error = xs_fmt("ERROR: unknown future version %lf\n", f);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ int db_upgrade(d_char **error)
|
||||||
fwrite(j, strlen(j), 1, f);
|
fwrite(j, strlen(j), 1, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
srv_log(xs_fmt("upgraded db %s after %d changes", fn, changed));
|
srv_log(xs_fmt("disk layout upgraded %s after %d changes", fn, changed));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
2
utils.c
2
utils.c
|
@ -103,7 +103,7 @@ int initdb(const char *basedir)
|
||||||
|
|
||||||
srv_config = xs_json_loads(default_srv_config);
|
srv_config = xs_json_loads(default_srv_config);
|
||||||
|
|
||||||
xs *layout = xs_number_new(db_layout);
|
xs *layout = xs_number_new(disk_layout);
|
||||||
srv_config = xs_dict_set(srv_config, "layout", layout);
|
srv_config = xs_dict_set(srv_config, "layout", layout);
|
||||||
|
|
||||||
printf("Network address [%s]:\n", xs_dict_get(srv_config, "address"));
|
printf("Network address [%s]:\n", xs_dict_get(srv_config, "address"));
|
||||||
|
|
Loading…
Reference in a new issue