X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=libopkg%2Fopkg_download.c;h=cfe8e68d93431cae6ec7d67d74f6ba2994ed2a8e;hb=1c1480e573fc6b4c5f9c51bf225c32456672e5f8;hp=373f2319e0b32c3ab5b06ad4c98e36438f9f6d27;hpb=293b1cef8b5a6de64d3fec87c01729b64006713a;p=project%2Fopkg-lede.git diff --git a/libopkg/opkg_download.c b/libopkg/opkg_download.c index 373f231..cfe8e68 100644 --- a/libopkg/opkg_download.c +++ b/libopkg/opkg_download.c @@ -206,6 +206,17 @@ opkg_download(const char *src, const char *dest_file_name, return err; } +static char* get_cache_filename(const char *dest_file_name) +{ + char *cache_name; + char *filename = strrchr(dest_file_name, '/'); + if (filename) + cache_name = xstrdup(filename + 1); // strip leading '/' + else + cache_name = xstrdup(dest_file_name); + return cache_name; +} + static int opkg_download_cache(const char *src, const char *dest_file_name) { @@ -223,11 +234,7 @@ opkg_download_cache(const char *src, const char *dest_file_name) goto out1; } - char *filename = strrchr(dest_file_name, '/'); - if (filename) - cache_name = xstrdup(filename + 1); // strip leading '/' - else - cache_name = xstrdup(dest_file_name); + cache_name = get_cache_filename(dest_file_name); sprintf_alloc(&cache_location, "%s/%s", conf->cache, cache_name); if (file_exists(cache_location)) opkg_msg(NOTICE, "Copying %s.\n", cache_location);