aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Roman <george.roman.99@gmail.com>2018-07-21 10:51:05 +0300
committerHisham Muhammad <hisham@gobolinux.org>2018-07-22 22:53:37 -0300
commitc212c884ff4be5d97d675e2390c6db47e18d6f8d (patch)
treed6017ae500dc55f0adf7af7b13141f27b609fe35
parent098fe3c52f1d400301124f5084b1972d57fd62d7 (diff)
downloadluarocks-c212c884ff4be5d97d675e2390c6db47e18d6f8d.tar.gz
luarocks-c212c884ff4be5d97d675e2390c6db47e18d6f8d.tar.bz2
luarocks-c212c884ff4be5d97d675e2390c6db47e18d6f8d.zip
fs.copy: skip copying if the source and destination are the same files
-rw-r--r--spec/build_spec.lua2
-rw-r--r--src/luarocks/fs/lua.lua3
2 files changed, 4 insertions, 1 deletions
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()
322 lfs.rmdir(tmpdir) 322 lfs.rmdir(tmpdir)
323 end) 323 end)
324 324
325 pending("LuaRocks build only deps of a given rock", function() 325 it("LuaRocks build only deps of a given rock", function()
326 local olddir = lfs.currentdir() 326 local olddir = lfs.currentdir()
327 local tmpdir = get_tmp_path() 327 local tmpdir = get_tmp_path()
328 lfs.mkdir(tmpdir) 328 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)
376 if destmode == "directory" then 376 if destmode == "directory" then
377 dest = dir.path(dest, dir.base_name(src)) 377 dest = dir.path(dest, dir.base_name(src))
378 end 378 end
379 if src == dest or (cfg.is_platform("unix") and lfs.attributes(src, "ino") == lfs.attributes(dest, "ino")) then
380 return nil, "The source and destination are the same files"
381 end
379 local src_h, err = io.open(src, "rb") 382 local src_h, err = io.open(src, "rb")
380 if not src_h then return nil, err end 383 if not src_h then return nil, err end
381 local dest_h, err = io.open(dest, "w+b") 384 local dest_h, err = io.open(dest, "w+b")