summaryrefslogtreecommitdiff
path: root/xmake/modules/private/action/require/impl
diff options
context:
space:
mode:
authorruki <[email protected]>2021-04-18 22:22:07 +0800
committerruki <[email protected]>2021-04-18 22:22:07 +0800
commitdbd3a2970da280b42f93a79caeb65e29034ba2bd (patch)
tree981074cc237eb45a6c6426d1ff738abeea7fc3da /xmake/modules/private/action/require/impl
parenta87d6552004a1fb9f89c29bb89f6918b22aedb3c (diff)
improve to search package file
Diffstat (limited to 'xmake/modules/private/action/require/impl')
-rw-r--r--xmake/modules/private/action/require/impl/actions/download.lua20
1 files changed, 15 insertions, 5 deletions
diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua
index 01d75025c..019b01ae8 100644
--- a/xmake/modules/private/action/require/impl/actions/download.lua
+++ b/xmake/modules/private/action/require/impl/actions/download.lua
@@ -118,14 +118,24 @@ function _download(package, url, sourcedir, url_alias, url_excludes)
os.tryrm(packagefile)
-- download or copy package file
- local localfile = find_file(path.filename(packagefile), core_package.searchdirs())
if os.isfile(url) then
os.cp(url, packagefile)
- elseif localfile and os.isfile(localfile) then
- -- we can use local package from the search directories directly if network is too slow
- os.cp(localfile, packagefile)
else
- http.download(url, packagefile)
+ local localfile
+ local searchnames = {package:name() .. "-" .. package:version_str() .. archive.extension(url),
+ packagefile}
+ for _, searchname in ipairs(searchnames) do
+ localfile = find_file(searchname, core_package.searchdirs())
+ if localfile then
+ break
+ end
+ end
+ if localfile and os.isfile(localfile) then
+ -- we can use local package from the search directories directly if network is too slow
+ os.cp(localfile, packagefile)
+ else
+ http.download(url, packagefile)
+ end
end
-- check hash