]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Attempt to mkdir the cache before cd'ing into it
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Mon, 14 Oct 2024 22:20:45 +0000 (16:20 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Mon, 14 Oct 2024 22:26:43 +0000 (16:26 -0600)
Probably not very useful outside of testing environments because of
permissions.

src/cache.c

index ed454813c97e0cc155f70a69b0eb5fb1c9edb599..0d3dbe205a7d58c3f609d7e89cd67ca34af8ef02 100644 (file)
@@ -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