[pacman-dev] [PATCH] Not trigger twice progressbar on some redirections

Alexandre Filgueira alexfilgueira at cinnarch.com
Fri Jan 11 05:00:29 EST 2013


I found that pacman was triggerin the progressbar callback twice when
pointing to my repo, which uses Mirrorbrain to geolocate the closest mirror.
After asking here in this list and in the curl library list, the thing was
that my header redirection response had a body, so curl was triggering
twice, downloading first just bytes (of the redirection) and then the
proper file.
I changed the dload.c code to avoid this, I don't know if it is correct to
do it the way I did. Now is triggering just once.

This is my modifications:

--- dload_original.c 2013-01-11 10:48:21.751443000 +0100
+++ dload_new.c 2013-01-11 10:44:13.049630000 +0100
@@ -95,6 +95,8 @@
 {
  struct dload_payload *payload = (struct dload_payload *)file;
  off_t current_size, total_size;
+ alpm_handle_t *handle = payload->handle;
+ CURL *curl = get_libcurl_handle(handle);

  /* SIGINT sent, abort by alerting curl */
  if(dload_interrupted) {
@@ -103,6 +105,13 @@

  current_size = payload->initial_size + (off_t)dlnow;

+ /* not show progressbar when redirection has body*/
+ long respcode = 0;
+ curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &respcode);
+ if (respcode == 302 && current_size > 0) {
+ return 0;
+ }
+
  /* is our filesize still under any set limit? */
  if(payload->max_size && current_size > payload->max_size) {
  dload_interrupted = ABORT_OVER_MAXFILESIZE;


More information about the pacman-dev mailing list