From 316bd60579ea11daca4fa25e2720b7fa147cc7ba Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 30 May 2018 23:53:26 +0200 Subject: git-receiver: centralize settings to reuse later --- src/blogc-git-receiver/pre-receive.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/blogc-git-receiver/pre-receive.c') diff --git a/src/blogc-git-receiver/pre-receive.c b/src/blogc-git-receiver/pre-receive.c index 20c6738..3668f8b 100644 --- a/src/blogc-git-receiver/pre-receive.c +++ b/src/blogc-git-receiver/pre-receive.c @@ -18,6 +18,7 @@ #include "../common/compat.h" #include "../common/utils.h" #include "../common/stdin.h" +#include "settings.h" #include "pre-receive-parser.h" #include "pre-receive.h" @@ -177,18 +178,15 @@ bgr_pre_receive_hook(int argc, char *argv[]) goto cleanup; } - char *home = getenv("BLOGC_GIT_RECEIVER_BASEDIR"); - if (home == NULL) { - home = getenv("HOME"); - } - if (home == NULL) { - fprintf(stderr, "error: failed to find user home path\n"); + const char *bd = bgr_settings_get_basedir(); + if (bd == NULL) { + fprintf(stderr, "error: failed to find user base directory path\n"); rv = 3; goto cleanup; } unsigned long epoch = time(NULL); - output_dir = bc_strdup_printf("%s/builds/%s-%lu", home, master, epoch); + output_dir = bc_strdup_printf("%s/builds/%s-%lu", bd, master, epoch); if (0 == access(output_dir, F_OK)) { char *tmp = output_dir; -- cgit v1.2.3-18-g5258