From: Alberto Leiva Popper Date: Mon, 14 Oct 2024 22:20:45 +0000 (-0600) Subject: Attempt to mkdir the cache before cd'ing into it X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6509e95653c5752878f99e470938546ab3c62045;p=thirdparty%2FFORT-validator.git Attempt to mkdir the cache before cd'ing into it Probably not very useful outside of testing environments because of permissions. --- diff --git a/src/cache.c b/src/cache.c index ed454813..0d3dbe20 100644 --- a/src/cache.c +++ b/src/cache.c @@ -232,10 +232,19 @@ init_cache_dirs(void) int cache_setup(void) { - if (chdir(config_get_local_repository()) < 0) { - pr_op_err("Cannot cd to the cache directory: %s", - strerror(errno)); - return errno; + char const *cachedir; + int error; + + cachedir = config_get_local_repository(); + + error = file_mkdir(cachedir, true); + if (error) + return error; + + if (chdir(cachedir) < 0) { + error = errno; + pr_op_err("Cannot cd to %s: %s", cachedir, strerror(error)); + return error; } // XXX Lock the cache directory