diff options
author | liugang <galen.gang.liu@gmail.com> | 2017-09-29 18:33:18 +0800 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-09-29 21:43:28 +0300 |
commit | c93bce78397de6cc96f0ed57ec4b01b582415db0 (patch) | |
tree | b7f1657bb6299776a00b04862c5af61bd02ed6ce | |
parent | 5e47739633969fcb08afe086de46c031c4a8d4d2 (diff) | |
download | meson-c93bce78397de6cc96f0ed57ec4b01b582415db0.zip meson-c93bce78397de6cc96f0ed57ec4b01b582415db0.tar.gz meson-c93bce78397de6cc96f0ed57ec4b01b582415db0.tar.bz2 |
Don't download patch archive if already download
the behavior of download patch should
keep same as download package.
-rw-r--r-- | mesonbuild/wrap/wrap.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 14529ab..81a2f88 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -292,15 +292,19 @@ class Resolver: raise RuntimeError('Incorrect hash for source %s:\n %s expected\n %s actual.' % (packagename, expected, dhash)) os.rename(tmpfile, ofname) if p.has_patch(): - purl = p.get('patch_url') - mlog.log('Downloading patch from', mlog.bold(purl)) - phash, tmpfile = self.get_data(purl) - expected = p.get('patch_hash') - if phash != expected: - os.remove(tmpfile) - raise RuntimeError('Incorrect hash for patch %s:\n %s expected\n %s actual' % (packagename, expected, phash)) - filename = os.path.join(self.cachedir, p.get('patch_filename')) - os.rename(tmpfile, filename) + patch_filename = p.get('patch_filename') + filename = os.path.join(self.cachedir, patch_filename) + if os.path.exists(filename): + mlog.log('Using', mlog.bold(patch_filename), 'from cache.') + else: + purl = p.get('patch_url') + mlog.log('Downloading patch from', mlog.bold(purl)) + phash, tmpfile = self.get_data(purl) + expected = p.get('patch_hash') + if phash != expected: + os.remove(tmpfile) + raise RuntimeError('Incorrect hash for patch %s:\n %s expected\n %s actual' % (packagename, expected, phash)) + os.rename(tmpfile, filename) else: mlog.log('Package does not require patch.') |