summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Jardón <jjardon@gnome.org>2020-03-29 09:22:16 +0000
committerJavier Jardón <jjardon@gnome.org>2020-03-29 09:22:16 +0000
commit73ef1f2ea9ed3377a3aa951fd920e52202c16b45 (patch)
tree84fa40ef437ac4632796ee9952c24e10e77c9548
parent9f7b8671b701381fea8ee61f789a5d6aa1759c78 (diff)
parentda6a333366aa07549969b92a135228f2e6dd4ab0 (diff)
downloadbuildstream-73ef1f2ea9ed3377a3aa951fd920e52202c16b45.tar.gz
Merge branch 'abderrahim/etag-1' into 'bst-1'
_downloadablefilesource.py: don't download the file if etag matches See merge request BuildStream/buildstream!1838
-rw-r--r--buildstream/plugins/sources/_downloadablefilesource.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/buildstream/plugins/sources/_downloadablefilesource.py b/buildstream/plugins/sources/_downloadablefilesource.py
index b4c7582fc..ab8140de0 100644
--- a/buildstream/plugins/sources/_downloadablefilesource.py
+++ b/buildstream/plugins/sources/_downloadablefilesource.py
@@ -121,7 +121,11 @@ class DownloadableFileSource(Source):
with contextlib.closing(urllib.request.urlopen(request)) as response:
info = response.info()
- etag = info['ETag'] if 'ETag' in info else None
+ # some servers don't honor the 'If-None-Match' header
+ if self.ref and etag and info["ETag"] == etag:
+ return self.ref
+
+ etag = info["ETag"]
filename = info.get_filename(default_name)
filename = os.path.basename(filename)