Skip to content

Commit 24dc3ae

Browse files
committedMar 6, 2016
Don't create download directories when not downloading uploads. (fixes #2260)
1 parent f347e37 commit 24dc3ae

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

Diff for: ‎nikola/plugins/command/import_wordpress.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,6 @@ def populate_context(self, channel):
446446

447447
def download_url_content_to_file(self, url, dst_path):
448448
"""Download some content (attachments) to a file."""
449-
if self.no_downloads:
450-
return
451-
452449
try:
453450
request = requests.get(url, auth=self.auth)
454451
if request.status_code >= 400:
@@ -468,10 +465,13 @@ def import_attachment(self, item, wordpress_namespace):
468465
'foo')
469466
path = urlparse(url).path
470467
dst_path = os.path.join(*([self.output_folder, 'files'] + list(path.split('/'))))
471-
dst_dir = os.path.dirname(dst_path)
472-
utils.makedirs(dst_dir)
473-
LOGGER.info("Downloading {0} => {1}".format(url, dst_path))
474-
self.download_url_content_to_file(url, dst_path)
468+
if self.no_downloads:
469+
dst_dir = os.path.dirname(dst_path)
470+
utils.makedirs(dst_dir)
471+
LOGGER.info("Downloading {0} => {1}".format(url, dst_path))
472+
self.download_url_content_to_file(url, dst_path)
473+
else:
474+
LOGGER.info("Skipping downloading {0} => {1}".format(url, dst_path))
475475
dst_url = '/'.join(dst_path.split(os.sep)[2:])
476476
links[link] = '/' + dst_url
477477
links[url] = '/' + dst_url

0 commit comments

Comments
 (0)
Please sign in to comment.