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 --- src/luarocks/fs/lua.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') 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