summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@redhat.com>2020-03-24 21:30:02 -0400
committerFrank Ch. Eigler <fche@redhat.com>2020-03-24 21:30:02 -0400
commit96966cd6d52398e703d163047719aee6d9e2eb1e (patch)
tree62f248aa56f7654667e211ed37ced9275ebcc490
parentc7316d9ff9ec78c41e321c8327b90e6e77517312 (diff)
downloadelfutils-96966cd6d52398e703d163047719aee6d9e2eb1e.tar.gz
debuginfod-client thinko: non-default progressfn extra output
A previous commit changed the default_progressfn output format to \rFOOBAR, to be terminated by an \n when the download finished. The \n terminator was conditional on the wrong thing (env var setting, rather than actual progressfn setting), so the \n could be printed even if an app overrode the default.
-rw-r--r--debuginfod/ChangeLog6
-rw-r--r--debuginfod/debuginfod-client.c70
2 files changed, 42 insertions, 34 deletions
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index 00e7ec63..b34b4d29 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -1,5 +1,11 @@
2020-03-24 Frank Ch. Eigler <fche@redhat.com>
+ * debuginfod-client.c (debuginfod_query_server): Print the
+ default_progressfn terminating \n message only if that progressfn
+ is actually set.
+
+2020-03-24 Frank Ch. Eigler <fche@redhat.com>
+
* debuginfod-find.c (main): Correct /source full-pathness check for
"debuginfod-find -v source deadbeef /pathname" case.
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
index 58a04b9a..ea2d1624 100644
--- a/debuginfod/debuginfod-client.c
+++ b/debuginfod/debuginfod-client.c
@@ -401,6 +401,41 @@ add_extra_headers(CURL *handle)
} \
} while (0)
+
+/* Offer a basic form of progress tracing */
+static int
+default_progressfn (debuginfod_client *c, long a, long b)
+{
+ const char* url = debuginfod_get_url (c);
+ int len = 0;
+
+ /* We prefer to print the host part of the URL to keep the
+ message short. */
+ if (url != NULL)
+ {
+ const char* buildid = strstr(url, "buildid/");
+ if (buildid != NULL)
+ len = (buildid - url);
+ else
+ len = strlen(url);
+ }
+
+ if (b == 0 || url==NULL) /* early stage */
+ dprintf(STDERR_FILENO,
+ "\rDownloading %c", "-/|\\"[a % 4]);
+ else if (b < 0) /* download in progress but unknown total length */
+ dprintf(STDERR_FILENO,
+ "\rDownloading from %.*s %ld",
+ len, url, a);
+ else /* download in progress, and known total length */
+ dprintf(STDERR_FILENO,
+ "\rDownloading from %.*s %ld/%ld",
+ len, url, a, b);
+
+ return 0;
+}
+
+
/* Query each of the server URLs found in $DEBUGINFOD_URLS for the file
with the specified build-id, type (debuginfo, executable or source)
and filename. filename may be NULL. If found, return a file
@@ -885,7 +920,7 @@ debuginfod_query_server (debuginfod_client *c,
/* general purpose exit */
out:
/* Conclude the last \r status line */
- if (getenv(DEBUGINFOD_PROGRESS_ENV_VAR))
+ if (c->progressfn == & default_progressfn)
dprintf(STDERR_FILENO, "\n");
free (cache_path);
@@ -898,39 +933,6 @@ debuginfod_query_server (debuginfod_client *c,
}
-/* Activate a basic form of progress tracing */
-static int
-default_progressfn (debuginfod_client *c, long a, long b)
-{
- const char* url = debuginfod_get_url (c);
- int len = 0;
-
- /* We prefer to print the host part of the URL to keep the
- message short. */
- if (url != NULL)
- {
- const char* buildid = strstr(url, "buildid/");
- if (buildid != NULL)
- len = (buildid - url);
- else
- len = strlen(url);
- }
-
- if (b == 0 || url==NULL) /* early stage */
- dprintf(STDERR_FILENO,
- "\rDownloading %c", "-/|\\"[a % 4]);
- else if (b < 0) /* download in progress but unknown total length */
- dprintf(STDERR_FILENO,
- "\rDownloading from %.*s %ld",
- len, url, a);
- else /* download in progress, and known total length */
- dprintf(STDERR_FILENO,
- "\rDownloading from %.*s %ld/%ld",
- len, url, a, b);
-
- return 0;
-}
-
/* See debuginfod.h */
debuginfod_client *