From 5641b64f3b051254ff8c9010f312bf35c750810e Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 17 Apr 2019 11:22:49 -0300 Subject: repos: prevent fs.move from failing Prevent fs.move from failing with ``` File already exists: /usr/local/share/lua/5.1/luasec_0_6_2-ssl.lua ``` when overwriting a stale file. This should have already been handled, but in case the manifest is out of sync for some reason this should make the behavior more smooth. --- src/luarocks/repos.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index eaec87b8..0058d928 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua @@ -262,6 +262,7 @@ end local function backup_existing(should_backup, target) if not should_backup then + fs.delete(target) return end if fs.exists(target) then @@ -301,6 +302,7 @@ local function op_rename(op) if fs.exists(op.src) then fs.make_dir(dir.dir_name(op.dst)) + fs.delete(op.dst) local ok, err = fs.move(op.src, op.dst) fs.remove_dir_tree_if_empty(dir.dir_name(op.src)) return ok, err -- cgit v1.2.3-55-g6feb