aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2019-03-28 23:39:53 -0300
committerHisham Muhammad <hisham@gobolinux.org>2019-04-01 16:29:17 -0300
commit4e97804fc1b8b47667ec1d8b8f3c473d31c8bb29 (patch)
tree3d86bf9e1d97365c61928ac59c99ff9e8454a1ec
parent7e9b7e08a8a31501189a32c60fb9cb7bc6b31b5e (diff)
downloadluarocks-4e97804fc1b8b47667ec1d8b8f3c473d31c8bb29.tar.gz
luarocks-4e97804fc1b8b47667ec1d8b8f3c473d31c8bb29.tar.bz2
luarocks-4e97804fc1b8b47667ec1d8b8f3c473d31c8bb29.zip
tar: do not attempt to create directory more than once
-rw-r--r--src/luarocks/tools/tar.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/luarocks/tools/tar.lua b/src/luarocks/tools/tar.lua
index 7828c517..a6a95252 100644
--- a/src/luarocks/tools/tar.lua
+++ b/src/luarocks/tools/tar.lua
@@ -4,7 +4,7 @@ local tar = {}
4 4
5local fs = require("luarocks.fs") 5local fs = require("luarocks.fs")
6local dir = require("luarocks.dir") 6local dir = require("luarocks.dir")
7local util = require("luarocks.util") 7local fun = require("luarocks.fun")
8 8
9local blocksize = 512 9local blocksize = 512
10 10
@@ -96,6 +96,7 @@ function tar.untar(filename, destdir)
96 96
97 local long_name, long_link_name 97 local long_name, long_link_name
98 local ok, err 98 local ok, err
99 local make_dir = fun.memoize(fs.make_dir)
99 while true do 100 while true do
100 local block 101 local block
101 repeat 102 repeat
@@ -132,14 +133,14 @@ function tar.untar(filename, destdir)
132 local pathname = dir.path(destdir, header.name) 133 local pathname = dir.path(destdir, header.name)
133 pathname = fs.absolute_name(pathname) 134 pathname = fs.absolute_name(pathname)
134 if header.typeflag == "directory" then 135 if header.typeflag == "directory" then
135 ok, err = fs.make_dir(pathname) 136 ok, err = make_dir(pathname)
136 if not ok then 137 if not ok then
137 break 138 break
138 end 139 end
139 elseif header.typeflag == "file" then 140 elseif header.typeflag == "file" then
140 local dirname = dir.dir_name(pathname) 141 local dirname = dir.dir_name(pathname)
141 if dirname ~= "" then 142 if dirname ~= "" then
142 ok, err = fs.make_dir(dirname) 143 ok, err = make_dir(dirname)
143 if not ok then 144 if not ok then
144 break 145 break
145 end 146 end