opkg: improve download error reporting
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 04:20:20 +0000 (04:20 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 04:20:20 +0000 (04:20 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@22 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

opkg_cmd.c
opkg_download.c

index 20d38720edb5323c9c0aad549ceb502b812e5685..db04a4a680fbd8ace0e114bfa681febf8d01d9eb 100644 (file)
@@ -287,6 +287,7 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
          err = opkg_download(conf, url, tmp_file_name);
          if (err) {
            failures++;
          err = opkg_download(conf, url, tmp_file_name);
          if (err) {
            failures++;
+               opkg_message (conf, OPKG_NOTICE, "Signature check failed\n");
          } else {
            int err;
            err = opkg_verify_file (list_file_name, tmp_file_name);
          } else {
            int err;
            err = opkg_verify_file (list_file_name, tmp_file_name);
@@ -296,6 +297,7 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
                opkg_message (conf, OPKG_NOTICE, "Signature check failed\n");
          }
          unlink (tmp_file_name);
                opkg_message (conf, OPKG_NOTICE, "Signature check failed\n");
          }
          unlink (tmp_file_name);
+         unlink (tmp);
          free (tmp_file_name);
 
          free (url);
          free (tmp_file_name);
 
          free (url);
index 63702508fd99413397a34070a1c63105f83a1822..161a5100363e917f8c92e3b0ec168ec29b106096 100644 (file)
@@ -60,6 +60,12 @@ curl_progress_func (char* url,
     }
 #endif
 
     }
 #endif
 
+    /* skip progress bar if we haven't done started yet
+     * this prevents drawing the progress bar if we receive an error such as
+     * file not found */
+    if (t == 0)
+       return 0;
+
     printf ("\r%3d%% |", p);
     for (i = 1; i < 73; i++)
     {
     printf ("\r%3d%% |", p);
     for (i = 1; i < 73; i++)
     {
@@ -166,7 +172,12 @@ int opkg_download(opkg_conf_t *conf, const char *src, const char *dest_file_name
        curl_easy_cleanup (curl);
        fclose (file);
        if (res)
        curl_easy_cleanup (curl);
        fclose (file);
        if (res)
+       {
+           long error_code;
+           curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &error_code);
+           opkg_message(conf, OPKG_ERROR, "Failed to download %s, error %d\n", src, error_code);
            return res;
            return res;
+       }
 
     }
     else
 
     }
     else