]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod-client: Update cache_path when the new default path exists
authorAaron Merey <amerey@redhat.com>
Tue, 3 Mar 2020 19:11:48 +0000 (14:11 -0500)
committerMark Wielaard <mark@klomp.org>
Wed, 4 Mar 2020 10:38:05 +0000 (11:38 +0100)
Update cache_path with the path of the new default directory when this
directory already exists. Previously cache_path was updated only when
creating the new default directory and would otherwise be set to the
old default path.

Signed-off-by: Aaron Merey <amerey@redhat.com>
debuginfod/ChangeLog
debuginfod/debuginfod-client.c
tests/run-debuginfod-find.sh

index 21d9ed87e43f3211cf9dbe66f70fb17fd8de470a..ab32b5236fbdbe19b29627be4460869f464d9ab7 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-03  Aaron Merey  <amerey@redhat.com>
+
+       * debuginfod-client.c (debuginfod_query_server): Update
+       cache_path even when new default path already exists.
+
 2020-02-27  Aaron Merey  <amerey@redhat.com>
 
        * debuginfod-client.c (xalloc_str): New macro. Call
index 2825e625442c6334d03ebb7d099d49ee7214fd0f..8923099fd89d554541d6443e5a29fb8c63f21539 100644 (file)
@@ -509,20 +509,18 @@ debuginfod_query_server (debuginfod_client *c,
 
               /* Also check for EEXIST and S_ISDIR in case another client just
                  happened to create the cache.  */
-              if (rc == 0
-                  || (errno == EEXIST
-                      && stat (cachedir, &st) != 0
-                      && S_ISDIR (st.st_mode)))
-                {
-                  free (cache_path);
-                  xalloc_str (cache_path, "%s/%s", cachedir, cache_xdg_name);
-                }
-              else
+              if (rc < 0
+                  && (errno != EEXIST
+                      || stat (cachedir, &st) != 0
+                      || ! S_ISDIR (st.st_mode)))
                 {
                   rc = -errno;
                   goto out;
                 }
             }
+
+          free (cache_path);
+          xalloc_str (cache_path, "%s/%s", cachedir, cache_xdg_name);
         }
     }
 
index 56e61216919b6ef40a47e1cd316d093b978af300..587eaaa3afa105197a3c68602b68da530368c91d 100755 (executable)
@@ -158,6 +158,13 @@ if [ ! -f $PWD/tmphome/.cache/debuginfod_client/$BUILDID/debuginfo ]; then
   exit 1
 fi
 
+# $HOME/.cache should be found.
+testrun env HOME=$PWD/tmphome XDG_CACHE_HOME= DEBUGINFOD_CACHE_PATH= ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID
+if [ ! -f $PWD/tmphome/.cache/debuginfod_client/$BUILDID/executable ]; then
+  echo "could not find cache in $PWD/tmphome/.cache"
+  exit 1
+fi
+
 # $XDG_CACHE_HOME should take priority over $HOME.cache.
 testrun env HOME=$PWD/tmphome XDG_CACHE_HOME=$PWD/tmpxdg DEBUGINFOD_CACHE_PATH= ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID
 if [ ! -f $PWD/tmpxdg/debuginfod_client/$BUILDID/debuginfo ]; then