Fix erroneous install errors when iterating on an archive (preserving its name but changing its contents).
Review Request #243 - Created March 29, 2011 and submitted
Alain Linden | Reviewers | ||
oz.linden, brad.linden, nat_linden | |||
None | autobuild |
Fixed a bug where an error would be thrown if one tried to install an archive with a filename that matches a cached version but is updated. One could hit this if they updated the same archive multiple times in a day (like when doing development work). Now if the cached archive doesn't match the hash, a download will be attempted so only true download errors will result in an exception.
Posted (March 29, 2011, 1:18 p.m.)
Couple comments. First, I think I missed a bet in my small change. Probably there should be a local hash_algorithm var: hash_algorithm = archive.hash_algorithm or "md5" if not hash_algorithms.verify_hash(hash_algorithm, cachefile, archive.hash): ... Second, I'm not enthused about the download_required flag. Three cases, right? * no such tarball in cache * tarball in cache by that name has wrong MD5 * tarball in cache by that name is correct So what about logic like this? if os.path.exists(cachefile): if hash_algorithms.verify_hash(archive.hash_algorithm, cachefile, archive.hash): logger.debug("found in cache: " + cachefile) else: # Cache contains tarball by that name, but wrong hash. Try downloading again. common.remove_package(archive.url) if not os.path.exists(cachefile): # download the package to the cache ...
Other reviews