From c212c884ff4be5d97d675e2390c6db47e18d6f8d Mon Sep 17 00:00:00 2001 From: George Roman Date: Sat, 21 Jul 2018 10:51:05 +0300 Subject: fs.copy: skip copying if the source and destination are the same files --- spec/build_spec.lua | 2 +- src/luarocks/fs/lua.lua | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 707ab145..62fbb353 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua @@ -322,7 +322,7 @@ describe("LuaRocks build tests #integration", function() lfs.rmdir(tmpdir) end) - pending("LuaRocks build only deps of a given rock", function() + it("LuaRocks build only deps of a given rock", function() local olddir = lfs.currentdir() local tmpdir = get_tmp_path() lfs.mkdir(tmpdir) diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 375cdee3..74d8f12f 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -376,6 +376,9 @@ function fs_lua.copy(src, dest, perms) if destmode == "directory" then dest = dir.path(dest, dir.base_name(src)) end + if src == dest or (cfg.is_platform("unix") and lfs.attributes(src, "ino") == lfs.attributes(dest, "ino")) then + return nil, "The source and destination are the same files" + end local src_h, err = io.open(src, "rb") if not src_h then return nil, err end local dest_h, err = io.open(dest, "w+b") -- cgit v1.2.3-55-g6feb