Skip to content

Commit

Permalink
Try to fix FileExistsError for action download #1295
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Peng committed Sep 23, 2019
1 parent a20e57e commit 3da1bb3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sos/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def action_wrapper(*args, **kwargs):
f'workdir option should be a path of type str or path, {kwargs["workdir"]} provided'
)
if not os.path.isdir(os.path.expanduser(kwargs['workdir'])):
os.makedirs(os.path.expanduser(kwargs['workdir']))
os.makedirs(os.path.expanduser(kwargs['workdir']), exist_ok=True)
try:
olddir = os.getcwd()
os.chdir(os.path.expanduser(kwargs['workdir']))
Expand Down Expand Up @@ -716,7 +716,7 @@ def downloadURL(URL, dest, decompress=False, index=None):
dest_dir, filename = os.path.split(dest)
#
if not os.path.isdir(dest_dir):
os.makedirs(dest_dir)
os.makedirs(dest_dir, exist_ok=True)
if not os.path.isdir(dest_dir):
raise RuntimeError(
f'Failed to create destination directory to download {URL}')
Expand Down

0 comments on commit 3da1bb3

Please sign in to comment.