From 01b8a1c87384508ec30eaf504e5af1a815afe8cb Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Wed, 18 Jan 2023 08:48:38 +0100 Subject: [PATCH] record-store: Allow overriding database location By setting the environment variable CALLS_RECORD_DIR the database location can be overriden which is useful for testing. --- src/calls-record-store.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calls-record-store.c b/src/calls-record-store.c index f5ff0f5..4369392 100644 --- a/src/calls-record-store.c +++ b/src/calls-record-store.c @@ -732,6 +732,7 @@ calls_record_store_init (CallsRecordStore *self) g_autofree char *new_dir = g_build_filename (g_get_user_data_dir (), APP_DATA_NAME, NULL); + const char *env_dir = g_getenv ("CALLS_RECORD_DIR"); char *used_dir = NULL; gboolean exist_old; gboolean exist_new; @@ -741,7 +742,9 @@ calls_record_store_init (CallsRecordStore *self) exist_new = g_file_test (new_dir, G_FILE_TEST_EXISTS); new_is_dir = g_file_test (new_dir, G_FILE_TEST_IS_DIR); - if (exist_old && !exist_new) { + if (env_dir) { + used_dir = (char *) env_dir; + } else if (exist_old && !exist_new) { g_debug ("Trying to move database from `%s' to `%s'", old_dir, new_dir); if (g_rename (old_dir, new_dir) == 0) {