@@ -165,12 +165,6 @@ def unpack_http_url(
165
165
# downloading archives, they have to be unpacked to parse dependencies
166
166
unpack_file (from_path , location , content_type )
167
167
168
- # a download dir is specified; let's copy the archive there
169
- if download_dir and not os .path .exists (
170
- os .path .join (download_dir , link .filename )
171
- ):
172
- _copy_file (from_path , download_dir , link )
173
-
174
168
return from_path
175
169
176
170
@@ -223,18 +217,13 @@ def unpack_file_url(
223
217
):
224
218
# type: (...) -> Optional[str]
225
219
"""Unpack link into location.
226
-
227
- If download_dir is provided and link points to a file, make a copy
228
- of the link file inside download_dir.
229
220
"""
230
221
link_path = link .file_path
231
222
# If it's a url to a local directory
232
223
if link .is_existing_dir ():
233
224
if os .path .isdir (location ):
234
225
rmtree (location )
235
226
_copy_source_tree (link_path , location )
236
- if download_dir :
237
- logger .info ('Link is a directory, ignoring download_dir' )
238
227
return None
239
228
240
229
# If a download dir is specified, is the file already there and valid?
@@ -263,12 +252,6 @@ def unpack_file_url(
263
252
# archives, they have to be unpacked to parse dependencies
264
253
unpack_file (from_path , location , content_type )
265
254
266
- # a download dir is specified and not already downloaded
267
- if download_dir and not os .path .exists (
268
- os .path .join (download_dir , link .filename )
269
- ):
270
- _copy_file (from_path , download_dir , link )
271
-
272
255
return from_path
273
256
274
257
@@ -280,14 +263,7 @@ def unpack_url(
280
263
hashes = None , # type: Optional[Hashes]
281
264
):
282
265
# type: (...) -> Optional[str]
283
- """Unpack link.
284
- If link is a VCS link:
285
- if only_download, export into download_dir and ignore location
286
- else unpack into location
287
- for other types of link:
288
- - unpack into location
289
- - if download_dir, copy the file into download_dir
290
- - if only_download, mark location for deletion
266
+ """Unpack link into location, downloading if required.
291
267
292
268
:param hashes: A Hashes object, one of whose embedded hashes must match,
293
269
or HashMismatch will be raised. If the Hashes is empty, no matches are
@@ -544,6 +520,14 @@ def prepare_linked_requirement(
544
520
req , self .req_tracker , self .finder , self .build_isolation ,
545
521
)
546
522
523
+ if download_dir :
524
+ if link .is_existing_dir ():
525
+ logger .info ('Link is a directory, ignoring download_dir' )
526
+ elif local_path and not os .path .exists (
527
+ os .path .join (download_dir , link .filename )
528
+ ):
529
+ _copy_file (local_path , download_dir , link )
530
+
547
531
if self ._download_should_save :
548
532
# Make a .zip of the source_dir we already created.
549
533
if link .is_vcs :
0 commit comments