From c98e167122252dad9e304259bb653e5d0402f1fc Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 29 Sep 2017 17:48:51 -0300 Subject: Be stricter when autodetecting `source.dir` Only assume directory is the location when the tarball contains only a single directory at the top level. --- src/luarocks/fetch.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 2cad3df2..6f8dfc0b 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua @@ -363,19 +363,18 @@ function fetch.get_sources(rockspec, extract, dest_dir) -- we're looking for. -- We only do this if the rockspec source.dir was not set, and only -- with rockspecs newer than 3.0. - local dir_count, found_dir = 0 + local file_count, found_dir = 0 if not rockspec.source.dir_set and rockspec:format_is_at_least("3.0") then - local files = fs.list_dir() - for _, f in ipairs(files) do - if fs.is_dir(f) then - dir_count = dir_count + 1 - found_dir = f + for file in fs.dir() do + file_count = file_count + 1 + if fs.is_dir(file) then + found_dir = file end end end - if dir_count == 1 then + if file_count == 1 and found_dir then rockspec.source.dir = found_dir else return nil, "Directory "..rockspec.source.dir.." not found inside archive "..rockspec.source.file, "source.dir", source_file, store_dir -- cgit v1.2.3-55-g6feb