From da6a333366aa07549969b92a135228f2e6dd4ab0 Mon Sep 17 00:00:00 2001 From: Abderrahim Kitouni Date: Wed, 18 Mar 2020 11:56:35 +0100 Subject: _downloadablefilesource.py: don't download the file if etag matches Some servers don't honor the 'If-None-Match' header and send the file even with matching etag --- buildstream/plugins/sources/_downloadablefilesource.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) -- cgit v1.2.1