X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=libopkg%2Fopkg_download.c;fp=libopkg%2Fopkg_download.c;h=59123d25babfa2d05cf373ead8ac04ec857af95a;hb=f73d42f0e951e71eae12ecac29b75b05ac543f5e;hp=cfe8e68d93431cae6ec7d67d74f6ba2994ed2a8e;hpb=1c1480e573fc6b4c5f9c51bf225c32456672e5f8;p=project%2Fopkg-lede.git diff --git a/libopkg/opkg_download.c b/libopkg/opkg_download.c index cfe8e68..59123d2 100644 --- a/libopkg/opkg_download.c +++ b/libopkg/opkg_download.c @@ -263,6 +263,8 @@ int opkg_download_pkg(pkg_t * pkg, const char *dir) char *stripped_filename; char *urlencoded_path; char *filename; + char *cache_name; + char *cache_location; if (pkg->src == NULL) { opkg_msg(ERROR, @@ -296,6 +298,23 @@ int opkg_download_pkg(pkg_t * pkg, const char *dir) sprintf_alloc(&local_filename, "%s/%s", dir, stripped_filename); pkg_set_string(pkg, PKG_LOCAL_FILENAME, local_filename); + /* Invalidate/remove cached package if it has an incorrect checksum. */ + if (conf->cache) { + cache_name = get_cache_filename(local_filename); + sprintf_alloc(&cache_location, "%s/%s", conf->cache, cache_name); + free(cache_name); + if (file_exists(cache_location)) { + err = opkg_verify_integrity(pkg, cache_location); + if (err) { + opkg_msg(NOTICE, + "Removing %s from cache because it has incorrect checksum.\n", + pkg->name); + unlink(cache_location); + } + } + free(cache_location); + } + err = opkg_download_cache(url, local_filename); free(url);