summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-05-04 00:46:07 +0800
committerruki <[email protected]>2019-05-03 22:36:44 +0800
commit237e520aadeb351dde886915d5369c7424aff7c5 (patch)
tree7770f780a86be528ea1e754fa635a566aaca3045
parent5ed784324f22c0c2d899a321341e0c1052fdef15 (diff)
improve to download package
-rw-r--r--xmake/actions/require/impl/action/download.lua14
-rw-r--r--xmake/actions/require/impl/package.lua7
2 files changed, 11 insertions, 10 deletions
diff --git a/xmake/actions/require/impl/action/download.lua b/xmake/actions/require/impl/action/download.lua
index c706892de..b445156ee 100644
--- a/xmake/actions/require/impl/action/download.lua
+++ b/xmake/actions/require/impl/action/download.lua
@@ -173,6 +173,7 @@ function main(package)
assert(#urls > 0, "cannot get url of package(%s)", package:name())
-- download package from urls
+ local ok = false
for idx, url in ipairs(urls) do
-- get url alias
@@ -185,7 +186,7 @@ function main(package)
url = filter.handle(url, package)
-- download url
- local ok = try
+ ok = try
{
function ()
@@ -205,12 +206,8 @@ function main(package)
function (errors)
-- show or save the last errors
- if errors then
- if (option.get("verbose") or option.get("diagnosis")) then
- cprint("${dim color.error}error: ${clear}%s", errors)
- else
- io.writefile(path.join(package:installdir("logs"), "download.txt"), errors)
- end
+ if errors and (option.get("verbose") or option.get("diagnosis")) then
+ cprint("${dim color.error}error: ${clear}%s", errors)
end
-- trace
@@ -222,7 +219,7 @@ function main(package)
end
-- failed? break it
- if idx == #urls and not package:requireinfo().optional then
+ if idx == #urls and not package:optional() then
raise("download failed!")
end
end
@@ -235,6 +232,7 @@ function main(package)
-- leave working directory
os.cd(oldir)
+ return ok
end
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua
index 64a9f2880..56f1b9f7e 100644
--- a/xmake/actions/require/impl/package.lua
+++ b/xmake/actions/require/impl/package.lua
@@ -580,15 +580,18 @@ function _install_packages(packages_install, packages_download)
end
-- download this package first
+ local downloaded = true
if packages_download[tostring(package)] then
packages_downloading[index] = package
- action.download(package)
+ downloaded = action.download(package)
packages_downloading[index] = nil
end
-- install this package
packages_installing[index] = package
- action.install(package)
+ if downloaded then
+ action.install(package)
+ end
packages_installing[index] = nil
-- mark this group as 'installed' or 'failed'