From 269fea9cb733bbdc77db6558af587feb28984961 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 25 Apr 2021 20:20:43 -0700 Subject: [PATCH] Fix special filenames being abspathed. --- voussoirkit/downloady.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/voussoirkit/downloady.py b/voussoirkit/downloady.py index ae3387d..cb07da9 100644 --- a/voussoirkit/downloady.py +++ b/voussoirkit/downloady.py @@ -64,15 +64,13 @@ def download_file( if localname in [None, '']: localname = basename_from_url(url) - localname = pathclass.Path(localname) - if localname.is_dir: - localname = localname.with_child(basename_from_url(url)) - - localname = localname.absolute_path - localname = sanitize_filename(localname) - if not is_special_file(localname): - localname = os.path.abspath(localname) + localname = pathclass.Path(localname) + if localname.is_dir: + localname = localname.with_child(basename_from_url(url)) + + localname = localname.absolute_path + localname = sanitize_filename(localname) log.debug('URL: %s', url) log.debug('File: %s', localname) @@ -100,7 +98,8 @@ def download_plan(plan): temp_localname = plan.download_into real_localname = plan.real_localname directory = os.path.split(temp_localname)[0] - if directory != '': + + if directory != '' and not is_special_file(temp_localname): os.makedirs(directory, exist_ok=True) if not is_special_file(temp_localname):