Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgandalf3 <gandalf3@blendermonkey.com>2017-08-29 09:41:54 +0300
committergandalf3 <gandalf3@blendermonkey.com>2017-08-29 09:41:54 +0300
commit16da5d84c0c4d5d630c4d42085f108ed7e0a40f8 (patch)
tree380c6b4141483812df4fada1389ba4840e2b1375
parent6d382129f9996e539cc0fd7061cd97798b06d489 (diff)
Wait until we've determined url is a real url to derive filenames from it
-rw-r--r--release/scripts/modules/bpkg/actions.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/release/scripts/modules/bpkg/actions.py b/release/scripts/modules/bpkg/actions.py
index 2d0e88d4a45..2dd2c0ab7c9 100644
--- a/release/scripts/modules/bpkg/actions.py
+++ b/release/scripts/modules/bpkg/actions.py
@@ -23,17 +23,7 @@ def download(url: str, destination: Path, progress_callback=None) -> Path:
progress_callback(0)
- # derive filename from url if `destination` is an existing directory, otherwise use `destination` directly
- if destination.is_dir():
- # TODO: get filename from Content-Disposition header, if available.
- from urllib.parse import urlsplit, urlunsplit
- parsed_url = urlsplit(url)
- local_filename = Path(parsed_url.path).name or 'download.tmp'
- local_fpath = destination / local_filename
- else:
- local_fpath = destination
-
- log.info('Downloading %s -> %s', url, local_fpath)
+ log.info('Downloading %s ', url)
# try:
resp = requests.get(url, stream=True, verify=True)
@@ -49,6 +39,18 @@ def download(url: str, destination: Path, progress_callback=None) -> Path:
log.info("Server responded 'Not Modified', not downloading")
return None
+ # determine destination filename from url, but only after we've determined it works as a real url
+ # derive filename from url if given `destination` is an existing directory,
+ # otherwise use `destination` directly
+ if destination.is_dir():
+ # TODO: get filename from Content-Disposition header, if available.
+ from urllib.parse import urlsplit, urlunsplit
+ parsed_url = urlsplit(url)
+ local_filename = Path(parsed_url.path).name or 'download.tmp'
+ local_fpath = destination / local_filename
+ else:
+ local_fpath = destination
+
try:
# Use float so that we can also use infinity
content_length = float(resp.headers['content-length'])