diff options
author | graham.gower@gmail.com <graham.gower@gmail.com@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2011-04-08 00:30:10 (EDT) |
---|---|---|
committer | graham.gower@gmail.com <graham.gower@gmail.com@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2011-04-08 00:30:10 (EDT) |
commit | d46db43e215d8f3b26e04c99f113db065040ef4c (patch) | |
tree | d51b2a44efa8072a2745734af41957dd9d2ab53e | |
parent | cc24363fb731bf71f06d4d758df30216967efdb0 (diff) |
Don't include the source URI in the cached filename.
This avoids multiple downloads in the case where a repository is simply a
mirror of another. The old, uri mangled, filename is still checked to ensure
backwards compatibility with existing caches.
Patch from robert.melchers@gmail.com.
git-svn-id: http://opkg.googlecode.com/svn/trunk@617 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
-rw-r--r-- | libopkg/opkg_download.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/libopkg/opkg_download.c b/libopkg/opkg_download.c index b9533aa..a1b8341 100644 --- a/libopkg/opkg_download.c +++ b/libopkg/opkg_download.c @@ -215,10 +215,23 @@ opkg_download_cache(const char *src, const char *dest_file_name, if (file_exists(cache_location)) opkg_msg(NOTICE, "Copying %s.\n", cache_location); else { - err = opkg_download(src, cache_location, cb, data, 0); - if (err) { - (void) unlink(cache_location); - goto out2; + /* cache file with funky name not found, try simple name */ + free(cache_name); + char *filename = strrchr(dest_file_name,'/'); + if (filename) + cache_name = xstrdup(filename+1); // strip leading '/' + else + cache_name = xstrdup(dest_file_name); + free(cache_location); + sprintf_alloc(&cache_location, "%s/%s", conf->cache, cache_name); + if (file_exists(cache_location)) + opkg_msg(NOTICE, "Copying %s.\n", cache_location); + else { + err = opkg_download(src, cache_location, cb, data); + if (err) { + (void) unlink(cache_location); + goto out2; + } } } |