@@ -625,7 +625,6 @@ def unpack_http_url(link, location, download_cache, download_dir=None,
625
625
def unpack_file_url (link , location , download_dir = None ):
626
626
627
627
link_path = url_to_path (link .url_without_fragment )
628
- from_path = None
629
628
already_downloaded = False
630
629
631
630
# If it's a url to a local directory
@@ -635,6 +634,11 @@ def unpack_file_url(link, location, download_dir=None):
635
634
shutil .copytree (link_path , location , symlinks = True )
636
635
return
637
636
637
+ # if link has a hash, let's confirm it matches
638
+ if link .hash :
639
+ link_path_hash = _get_hash_from_file (link_path , link )
640
+ _check_hash (link_path_hash , link )
641
+
638
642
# If a download dir is specified, is the file already there and valid?
639
643
if download_dir :
640
644
download_path = os .path .join (download_dir , link .filename )
@@ -655,16 +659,17 @@ def unpack_file_url(link, location, download_dir=None):
655
659
else :
656
660
already_downloaded = True
657
661
658
- # a download dir is specified and not already downloaded
659
- if download_dir and not already_downloaded :
660
- content_type = mimetypes .guess_type (link_path )[0 ]
661
- _copy_file (link_path , download_dir , content_type , link )
662
-
663
- # unpack the archive to the build dir location. even when only downloading
664
- # archives, they have to be unpacked to parse dependencies
665
662
if already_downloaded :
666
663
from_path = download_path
667
664
else :
668
665
from_path = link_path
666
+
669
667
content_type = mimetypes .guess_type (from_path )[0 ]
668
+
669
+ # unpack the archive to the build dir location. even when only downloading
670
+ # archives, they have to be unpacked to parse dependencies
670
671
unpack_file (from_path , location , content_type , link )
672
+
673
+ # a download dir is specified and not already downloaded
674
+ if download_dir and not already_downloaded :
675
+ _copy_file (from_path , download_dir , content_type , link )
0 commit comments