diff options
author | George Roman <george.roman.99@gmail.com> | 2018-07-21 10:51:05 +0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-22 22:53:37 -0300 |
commit | c212c884ff4be5d97d675e2390c6db47e18d6f8d (patch) | |
tree | d6017ae500dc55f0adf7af7b13141f27b609fe35 /src | |
parent | 098fe3c52f1d400301124f5084b1972d57fd62d7 (diff) | |
download | luarocks-c212c884ff4be5d97d675e2390c6db47e18d6f8d.tar.gz luarocks-c212c884ff4be5d97d675e2390c6db47e18d6f8d.tar.bz2 luarocks-c212c884ff4be5d97d675e2390c6db47e18d6f8d.zip |
fs.copy: skip copying if the source and destination are the same files
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/fs/lua.lua | 3 |
1 files changed, 3 insertions, 0 deletions
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") |