Skip to content

Commit

Permalink
fixed zip compress
Browse files Browse the repository at this point in the history
  • Loading branch information
cryi committed Oct 28, 2021
1 parent 5f89c7d commit f7a0355
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config.hjson
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
version: 0.17.2
version: 0.17.3
global_modules: false//disables global modules loading (only looks up for modules in cwd)
minify: true
inject_CA: true
Expand Down
2 changes: 1 addition & 1 deletion lib/eli/zip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ function zip.compress(source, target, options)
_skipLength = #source - #_targetName + 1
end

local _archive = _lzip.new_archive(target)
local _archive = zip.new_archive(target)
if fs.file_type(source) == "file" then
zip.add_to_archive(_archive, source:sub(_skipLength), "file", source)
_archive:close()
Expand Down
2 changes: 1 addition & 1 deletion lib/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ local function eli_init()
end
APP_ROOT = path.dir(APP_ROOT_SCRIPT)
end
ELI_LIB_VERSION = "0.17.2"
ELI_LIB_VERSION = "0.17.3"

local _elify = true
for i, v in ipairs(arg) do
Expand Down
13 changes: 13 additions & 0 deletions lib/tests/zip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ _test["extract_string"] = function ()
_test.assert(_hash == _hash2, "hashes dont match")
end

_test["compress"] = function ()
_eliFs.remove("tmp/test.file.zip")
local _ok, _file = _eliZip.safe_compress("assets/test.file", "tmp/test.file.zip")
_test.assert(_ok, _file)
local _ok, _error = _eliZip.safe_extract_file("tmp/test.file.zip", "test.file", "tmp/test.file.unzipped")
_test.assert(_ok, _error)
local _ok, _hash = _eliFs.safe_hash_file("tmp/test.file.unzipped", {hex = true})
local _ok, _hash2 = _eliFs.safe_hash_file("assets/test.file", {hex = true})
local _ok, _hash2 = _eliFs.safe_hash_file("assets/test.file", {hex = true})
_test.assert(_ok, _hash2)
_test.assert(_hash == _hash2, "hashes dont match")
end

if not TEST then
_test.summary()
end

0 comments on commit f7a0355

Please sign in to comment.