public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Aaron Merey <amerey@redhat.com>
To: elfutils-devel@sourceware.org
Subject: [PATCH] debuginfod-client: update cache_path when new default path exists
Date: Tue, 03 Mar 2020 19:33:00 -0000	[thread overview]
Message-ID: <CAJDtP-ToGKQZeeAOpWgVT12yCTCDTh7MR6rfyVNm=7wzFBjYpw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2 bytes --]



[-- Attachment #2: 0001-debuginfod-client-Update-cache_path-when-the-new-def.patch --]
[-- Type: text/x-patch, Size: 3156 bytes --]

From 46010f911b72610452c2c58a709af8609992225b Mon Sep 17 00:00:00 2001
From: Aaron Merey <amerey@redhat.com>
Date: Tue, 3 Mar 2020 14:11:48 -0500
Subject: [PATCH] debuginfod-client: Update cache_path when the new default
 path exists

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           |  5 +++++
 debuginfod/debuginfod-client.c | 16 +++++++---------
 tests/run-debuginfod-find.sh   |  7 +++++++
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index 21d9ed87..ab32b523 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -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
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
index 2825e625..8923099f 100644
--- a/debuginfod/debuginfod-client.c
+++ b/debuginfod/debuginfod-client.c
@@ -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);
         }
     }
 
diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh
index 56e61216..587eaaa3 100755
--- a/tests/run-debuginfod-find.sh
+++ b/tests/run-debuginfod-find.sh
@@ -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
-- 
2.24.1


             reply	other threads:[~2020-03-03 19:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-03 19:33 Aaron Merey [this message]
2020-03-04 10:55 ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJDtP-ToGKQZeeAOpWgVT12yCTCDTh7MR6rfyVNm=7wzFBjYpw@mail.gmail.com' \
    --to=amerey@redhat.com \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).