summaryrefslogtreecommitdiff
path: root/buildstream
diff options
context:
space:
mode:
authorAbderrahim Kitouni <akitouni@gnome.org>2020-03-18 11:56:35 +0100
committerAbderrahim Kitouni <akitouni@gnome.org>2020-03-24 11:05:21 +0100
commitda6a333366aa07549969b92a135228f2e6dd4ab0 (patch)
tree84fa40ef437ac4632796ee9952c24e10e77c9548 /buildstream
parent9f7b8671b701381fea8ee61f789a5d6aa1759c78 (diff)
downloadbuildstream-da6a333366aa07549969b92a135228f2e6dd4ab0.tar.gz
_downloadablefilesource.py: don't download the file if etag matchesabderrahim/etag-1
Some servers don't honor the 'If-None-Match' header and send the file even with matching etag
Diffstat (limited to 'buildstream')
-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)