aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2021-12-02 15:05:07 +0100
committerWilliam Boman <william@redwill.se>2021-12-02 15:05:07 +0100
commit1e2acb0b71dbeec144f2e19f816f995f80b0976e (patch)
tree533906f156c5f386d723560c901d4e3689350824 /lua
parentfix(clangd): check non-nil before trying to format (diff)
downloadmason-1e2acb0b71dbeec144f2e19f816f995f80b0976e.tar
mason-1e2acb0b71dbeec144f2e19f816f995f80b0976e.tar.gz
mason-1e2acb0b71dbeec144f2e19f816f995f80b0976e.tar.bz2
mason-1e2acb0b71dbeec144f2e19f816f995f80b0976e.tar.lz
mason-1e2acb0b71dbeec144f2e19f816f995f80b0976e.tar.xz
mason-1e2acb0b71dbeec144f2e19f816f995f80b0976e.tar.zst
mason-1e2acb0b71dbeec144f2e19f816f995f80b0976e.zip
server: always delete the tmp install dir if installation fails
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-lsp-installer/server.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/lua/nvim-lsp-installer/server.lua b/lua/nvim-lsp-installer/server.lua
index aeaa5ba2..56ae77b5 100644
--- a/lua/nvim-lsp-installer/server.lua
+++ b/lua/nvim-lsp-installer/server.lua
@@ -122,9 +122,13 @@ function M.Server:install(version)
status_win().install_server(self, version)
end
+function M.Server:get_tmp_install_dir()
+ return path.concat { settings.current.install_root_dir, ("%s.tmp"):format(self.name) }
+end
+
---@param context ServerInstallContext
function M.Server:_setup_install_context(context)
- context.install_dir = path.concat { settings.current.install_root_dir, ("%s.tmp"):format(self.name) }
+ context.install_dir = self:get_tmp_install_dir()
fs.rm_mkdirp(context.install_dir)
if not fs.dir_exists(settings.current.install_root_dir) then
@@ -182,6 +186,7 @@ function M.Server:install_attached(context, callback)
context.stdio_sink.stderr(
("Failed to promote the temporary installation directory %q.\n"):format(context.install_dir)
)
+ pcall(fs.rmrf, self:get_tmp_install_dir())
callback(false)
return
end
@@ -195,7 +200,7 @@ function M.Server:install_attached(context, callback)
end)
callback(true)
else
- pcall(fs.rmrf, context.install_dir)
+ pcall(fs.rmrf, self:get_tmp_install_dir())
callback(false)
end
end),