mirror of
https://github.com/0x5eal/luau-unzip.git
synced 2025-04-10 17:20:53 +01:00
feat: simplify path construction logic
Simplies logic to just use nearest parent as the base instead of traversing downwards. This reduces some redundancy, however fixes a bug with repeated components in the constructed path and also improves performance by skipping a loop altogether. Also fixes recursive extraction tests failing `pandoc_soft_links.zip`.
This commit is contained in:
parent
54d46ff9cc
commit
6182e65756
2 changed files with 11 additions and 7 deletions
|
@ -163,14 +163,19 @@ function ZipEntry.isSymlink(self: ZipEntry): boolean
|
||||||
end
|
end
|
||||||
|
|
||||||
function ZipEntry.getPath(self: ZipEntry): string
|
function ZipEntry.getPath(self: ZipEntry): string
|
||||||
local path = self.name
|
if self.name == "/" then
|
||||||
local current = self.parent
|
return "/"
|
||||||
|
|
||||||
while current and current.name ~= "/" do
|
|
||||||
path = current.name .. path
|
|
||||||
current = current.parent
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get just the entry name without the path
|
||||||
|
local name = string.match(self.name, "([^/]+)/?$") or self.name
|
||||||
|
|
||||||
|
if not self.parent or self.parent.name == "/" then
|
||||||
|
return self.name
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Combine parent path with entry name
|
||||||
|
local path = string.gsub(self.parent:getPath() .. name, "//+", "/")
|
||||||
return path
|
return path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ local FALLIBLES = {
|
||||||
"invalid_offset2.zip",
|
"invalid_offset2.zip",
|
||||||
"chinese.zip", -- Contains non local specific encoding which can't be parsed without OS APIs
|
"chinese.zip", -- Contains non local specific encoding which can't be parsed without OS APIs
|
||||||
"non_utf8.zip", -- FIXME: Lune breaks for non utf8 data in process stdout
|
"non_utf8.zip", -- FIXME: Lune breaks for non utf8 data in process stdout
|
||||||
"pandoc_soft_links.zip", -- Soft links are tested separately in edge_cases
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return function(test: typeof(frktest.test))
|
return function(test: typeof(frktest.test))
|
||||||
|
|
Loading…
Add table
Reference in a new issue