sync

Backup service to store encrypted wallet databases (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit 2d5ee6ab69b8abd8aa607deb45bdc08e4cad3369
parent ea203ef668ce4be4e92048b4b4ab8c8d2ff721bc
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 14 Jun 2026 01:38:18 +0200

re-add check to refuse to start if schema is not current

Diffstat:
Msrc/include/sync/sync_database_lib.h | 15++++++++++++++-
Msrc/syncdb/syncdb_pg.c | 42+++++++++++++++++++++++++++++++++++++++---
2 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/src/include/sync/sync_database_lib.h b/src/include/sync/sync_database_lib.h @@ -40,7 +40,20 @@ * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure */ enum GNUNET_GenericReturnValue -SYNCDB_init (const struct GNUNET_CONFIGURATION_Handle *cfg); +SYNCDB_init ( + const struct GNUNET_CONFIGURATION_Handle *cfg); + + +/** + * Initialize the sync database subsystem for administration. + * Disables the check that the database schema is current. + * + * @param cfg configuration to use + * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure + */ +enum GNUNET_GenericReturnValue +SYNCDB_init_admin ( + const struct GNUNET_CONFIGURATION_Handle *cfg); /** diff --git a/src/syncdb/syncdb_pg.c b/src/syncdb/syncdb_pg.c @@ -80,8 +80,16 @@ reconnect_cb (struct PostgresClosure *pg_, } -enum GNUNET_GenericReturnValue -SYNCDB_init (const struct GNUNET_CONFIGURATION_Handle *cfg) +/** + * Initialize the database connection. + * + * @param cfg configuration to use + * @param check_current true to check if the database schema is current + * @return NULL on failure + */ +static enum GNUNET_GenericReturnValue +do_init (const struct GNUNET_CONFIGURATION_Handle *cfg, + bool check_current) { pg = GNUNET_new (struct PostgresClosure); pg->cfg = cfg; @@ -98,7 +106,7 @@ SYNCDB_init (const struct GNUNET_CONFIGURATION_Handle *cfg) return GNUNET_SYSERR; } pg->conn = GNUNET_PQ_init (pg->cfg, - "merchantdb-postgres", + "syncdb-postgres", &reconnect_cb, pg); if (NULL == pg->conn) @@ -106,10 +114,38 @@ SYNCDB_init (const struct GNUNET_CONFIGURATION_Handle *cfg) SYNCDB_fini (); return GNUNET_NO; } + if (check_current && + (GNUNET_OK != + GNUNET_PQ_check_current (pg->conn, + "sync-")) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Database schema is not up-to-date. Try running taler-merchant-dbinit or taler-merchant-dbconfig!\n"); + SYNCDB_fini (); + return GNUNET_NO; + } return GNUNET_OK; } +enum GNUNET_GenericReturnValue +SYNCDB_init ( + const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + return do_init (cfg, + true); +} + + +enum GNUNET_GenericReturnValue +SYNCDB_init_admin ( + const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + return do_init (cfg, + false); +} + + void SYNCDB_fini (void) {