Checks if the signature already exists in cache before attempting the
download. Previously, every call to 'opkg upgrade' would download the
signature. This led to problems in the following scenario:
* Call 'opkg --download-only upgrade' to download any package upgrades.
* Disconnect the package repository (i.e. disconnect removable media)
* Call 'opkg upgrade'
Previously 'opkg upgrade' would fail because it could not download the
signature files. The upgrade now works in this scenario.
Signed-off-by: Bryan Evenson <
beve...@cinci.rr.com>
---
libopkg/opkg_download.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/libopkg/opkg_download.c b/libopkg/opkg_download.c
index 5c74f66..79b8435 100644
--- a/libopkg/opkg_download.c
+++ b/libopkg/opkg_download.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <libgen.h>
+#include <sys/stat.h>
#include "opkg_download.h"
#include "opkg_message.h"
@@ -248,12 +249,20 @@ static char *get_pkg_url(pkg_t * pkg)
return url;
}
+/** \brief pkg_download_signature: download a package signature
+ * \details First checks if the signature has already been downloaded
+ *
+ * \param pkg the package associated with the signature
+ * \return The signature filename if success, NULL if error occurs
+ *
+ */
char *pkg_download_signature(pkg_t * pkg)
{
char *pkg_url;
char *sig_url;
char *sig_ext;
char *sig_file;
+ struct stat sig_stat;
pkg_url = get_pkg_url(pkg);
if (!pkg_url)
@@ -267,7 +276,11 @@ char *pkg_download_signature(pkg_t * pkg)
sprintf_alloc(&sig_url, "%s.%s", pkg_url, sig_ext);
free(pkg_url);
- sig_file = opkg_download_cache(sig_url, NULL, NULL);
+ sig_file = get_cache_location(sig_url);
+ if (stat(sig_file, &sig_stat)) {
+ free(sig_file);
+ sig_file = opkg_download_cache(sig_url, NULL, NULL);
+ }
free(sig_url);
return sig_file;
--
2.17.1