Move directory handling from unpack_file_url to unpack_url
@@ -213,16 +213,9 @@ def unpack_file_url(
download_dir=None, # type: Optional[str]
hashes=None # type: Optional[Hashes]
):
- # type: (...) -> Optional[str]
+ # type: (...) -> str
"""Unpack link into location.
"""
- # If it's a url to a local directory
- if link.is_existing_dir():
- if os.path.isdir(location):
- rmtree(location)
- _copy_source_tree(link.file_path, location)
- return None
-
# If a download dir is specified, is the file already there and valid?
already_downloaded_path = None
if download_dir:
@@ -272,6 +265,13 @@ def unpack_url(
unpack_vcs_link(link, location)
return None
+ # If it's a url to a local directory
+ if link.is_existing_dir():
+ if os.path.isdir(location):
+ rmtree(location)
+ _copy_source_tree(link.file_path, location)
+ return None
+
# file urls
if link.is_file:
return unpack_file_url(link, location, download_dir, hashes=hashes)
