diff options
| author | ruki <[email protected]> | 2023-08-31 22:33:50 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-08-31 22:33:50 +0800 |
| commit | 025c5e8415b456bf5f24e37322731615bd5ddea1 (patch) | |
| tree | 3bbf88dc48d70e4c362e15589967c271f5ce844f | |
| parent | 56c0b2a45c2c31d14a07dc684e2193447cd2e2e7 (diff) | |
support to download plain resource file
| -rw-r--r-- | xmake/modules/private/action/require/impl/actions/download.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/actions/download_resources.lua | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua index f222fcd39..d0d5c67d5 100644 --- a/xmake/modules/private/action/require/impl/actions/download.lua +++ b/xmake/modules/private/action/require/impl/actions/download.lua @@ -233,7 +233,7 @@ function _download(package, url, sourcedir, opt) os.mkdir(sourcedir) raise("cannot extract %s, maybe missing extractor or invalid package file!", packagefile) else - -- if it is not archive file, we only need to create empty source file and use package:originfile() + -- if it is not archive file, we only need to create empty source directory and use package:originfile() os.tryrm(sourcedir) os.mkdir(sourcedir) end diff --git a/xmake/modules/private/action/require/impl/actions/download_resources.lua b/xmake/modules/private/action/require/impl/actions/download_resources.lua index 194afd3e6..9fc3da6c2 100644 --- a/xmake/modules/private/action/require/impl/actions/download_resources.lua +++ b/xmake/modules/private/action/require/impl/actions/download_resources.lua @@ -123,7 +123,8 @@ function _download(package, resource_name, resource_url, resource_hash) -- check hash if resource_hash and resource_hash ~= hash.sha256(resource_file) then - raise("resource(%s): unmatched checksum!", resource_url) + raise("resource(%s): unmatched checksum, current hash(%s) != original hash(%s)", resource_url, + hash.sha256(resource_file):sub(1, 8), resource_hash:sub(1, 8)) end end @@ -131,12 +132,18 @@ function _download(package, resource_name, resource_url, resource_hash) local resourcedir = package:resourcedir(resource_name) local resourcedir_tmp = resourcedir .. ".tmp" os.tryrm(resourcedir_tmp) + local extension = archive.extension(resource_file) if archive.extract(resource_file, resourcedir_tmp) then os.tryrm(resourcedir) os.mv(resourcedir_tmp, resourcedir) - else + elseif extension and extension ~= "" then os.tryrm(resourcedir_tmp) + os.tryrm(resourcedir) raise("cannot extract %s", resource_file) + else + -- if it is not archive file, we only need to create empty resource directory and use package:resourcefile(resource_name) + os.tryrm(resourcedir) + os.mkdir(resourcedir) end end |
