---
lib/gitano/util.lua | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/lib/gitano/util.lua b/lib/gitano/util.lua
index a07b410..dd40eb3 100644
--- a/lib/gitano/util.lua
+++ b/lib/gitano/util.lua
@@ -299,23 +299,6 @@ end
local _exclude_builtin = { ["."] = true, [".."] = true }
local copy_dir_filter_base = copy_pathname_filter(_exclude_builtin)
-local function gen_cb(cbs, ftype, fname)
- if ftype == luxio.DT_UNKNOWN then
- local statdata, err = sio.lstat(fname)
- if not statdata then
- return nil, err
- end
- if luxio.S_ISDIR(statdata.mode) ~= 0 then
- ftype = luxio.DT_DIR
- elseif luxio.S_ISLNK(statdata.mode) ~= 0 then
- ftype = luxio.DT_LNK
- elseif luxio.S_ISREG(statdata.mode) ~= 0 then
- ftype = luxio.DT_REG
- end
- end
- return cbs[ftype], "No callback provided"
-end
-
local copy_dir_copy_callbacks
-- filter_cb is a function, which takes (parent_path, filename, fileinfo)
-- and returns true if the component should not be copied
@@ -335,10 +318,27 @@ local function copy_dir(from, to, copy_cbs, filter_cb)
end
for filename, fileinfo in dirp:iterate() do
local filefrom = path_join(from, filename)
+ if fileinfo.d_type == luxio.DT_UNKNOWN then
+ -- Stat and translate mode to type if type unknown
+ local stat, err = sio.lstat(filefrom)
+ if not stat then
+ log.critical("Stat file", filefrom, "failed:", err)
+ return false, err
+ end
+ fileinfo.d_type = ({
+ [luxio.S_IFBLK] = luxio.DT_BLK,
+ [luxio.S_IFCHR] = luxio.DT_CHR,
+ [luxio.S_IFDIR] = luxio.DT_DIR,
+ [luxio.S_IFIFO] = luxio.DT_FIFO,
+ [luxio.S_IFLNK] = luxio.DT_LNK,
+ [luxio.S_IFREG] = luxio.DT_REG,
+ [luxio.S_IFSOCK] = luxio.DT_SOCK,
+ })[luxio.bit.band(stat.mode, luxio.S_IFMT)]
+ end
local fileto = path_join(to, filename)
- local copycb, err = gen_cb(copy_cbs, fileinfo.d_type, filefrom)
+ local copycb = copy_cbs[fileinfo.d_type]
if not copycb then
- return false, err
+ return false, "No callback provided"
end
if filter_cb(from, filename, fileinfo) then
log.ddebug("Skipping file", filename)
--
1.9.1