[pacman-dev,6/7] make alpm download config accessible without curl

Message ID 20210116072101.38203-6-andrew.gregory.8@gmail.com
State New
Headers show
Series [pacman-dev,1/7] pacman: indicate --overwrite takes a glob | expand

Commit Message

Andrew Gregory Jan. 16, 2021, 7:21 a.m. UTC
Download-related config options are currently limited to builds with
curl.  This causes compilation errors when those options are used
without an appropriate guard which often goes unnoticed because we all
use curl.  Front-ends providing their own download callback may also
want to use these settings.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
---

I saw the patch to hide the offending use of parallel_downloads after
I wrote this.  I think it makes more sense to just make these
available to the front-end; we've already had one attempt to
parallelize xfercommand.

 lib/libalpm/handle.c | 12 ------------
 lib/libalpm/handle.h |  3 ++-
 2 files changed, 2 insertions(+), 13 deletions(-)

Comments

Emil Velikov Jan. 16, 2021, 2:50 p.m. UTC | #1
On Sat, 16 Jan 2021 at 07:23, Andrew Gregory <andrew.gregory.8@gmail.com> wrote:
>
> Download-related config options are currently limited to builds with
> curl.  This causes compilation errors when those options are used
> without an appropriate guard which often goes unnoticed because we all
> use curl.  Front-ends providing their own download callback may also
> want to use these settings.
>
> Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
> ---
>
> I saw the patch to hide the offending use of parallel_downloads after
> I wrote this.  I think it makes more sense to just make these
> available to the front-end; we've already had one attempt to
> parallelize xfercommand.
>
As the author of said patch your fix seems better IMHO.
The only thing I'd suggest is adding a Fixes-style reference for the
"offending" commit. Here and for other patches in this series.

Thanks
-Emil
P.S. Didn't see the gitlab-ci.yml until Allan mentioned. Props for
keeping an eye on the results.

Patch

diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 3994f314..0444ee5d 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -303,11 +303,7 @@  const char SYMEXPORT *alpm_option_get_dbext(alpm_handle_t *handle)
 int SYMEXPORT alpm_option_get_parallel_downloads(alpm_handle_t *handle)
 {
 	CHECK_HANDLE(handle, return -1);
-#ifdef HAVE_LIBCURL
 	return handle->parallel_downloads;
-#else
-	return 1;
-#endif
 }
 
 int SYMEXPORT alpm_option_set_logcb(alpm_handle_t *handle, alpm_cb_log cb)
@@ -854,11 +850,7 @@  int SYMEXPORT alpm_option_set_disable_dl_timeout(alpm_handle_t *handle,
 		unsigned short disable_dl_timeout)
 {
 	CHECK_HANDLE(handle, return -1);
-#ifdef HAVE_LIBCURL
 	handle->disable_dl_timeout = disable_dl_timeout;
-#else
-	(void)disable_dl_timeout; /* silence unused variable warnings */
-#endif
 	return 0;
 }
 
@@ -866,11 +858,7 @@  int SYMEXPORT alpm_option_set_parallel_downloads(alpm_handle_t *handle,
 		unsigned int num_streams)
 {
 	CHECK_HANDLE(handle, return -1);
-#ifdef HAVE_LIBCURL
 	ASSERT(num_streams >= 1, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
 	handle->parallel_downloads = num_streams;
-#else
-	(void)num_streams; /* silence unused variable warnings */
-#endif
 	return 0;
 }
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index 9fef0fbf..3e7d323e 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -60,9 +60,10 @@  struct __alpm_handle_t {
 #ifdef HAVE_LIBCURL
 	/* libcurl handle */
 	CURLM *curlm;
+#endif
+
 	unsigned short disable_dl_timeout;
 	unsigned int parallel_downloads; /* number of download streams */
-#endif
 
 #ifdef HAVE_LIBGPGME
 	alpm_list_t *known_keys;  /* keys verified to be in our keychain */