From b68fcc6bb2c770495ff8e2508c06dfdd49abcc80 Mon Sep 17 00:00:00 2001 From: William Boman Date: Thu, 21 Apr 2022 12:09:59 +0200 Subject: chore: refactor remaining installers to async impl (#616) --- lua/nvim-lsp-installer/core/fs.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lua/nvim-lsp-installer/core/fs.lua') diff --git a/lua/nvim-lsp-installer/core/fs.lua b/lua/nvim-lsp-installer/core/fs.lua index b915baf5..5106b40a 100644 --- a/lua/nvim-lsp-installer/core/fs.lua +++ b/lua/nvim-lsp-installer/core/fs.lua @@ -1,6 +1,8 @@ local uv = require "nvim-lsp-installer.core.async.uv" local log = require "nvim-lsp-installer.log" local a = require "nvim-lsp-installer.core.async" +local Path = require "nvim-lsp-installer.path" +local settings = require "nvim-lsp-installer.settings" local M = {} @@ -31,6 +33,12 @@ end ---@async ---@param path string function M.rmrf(path) + assert( + Path.is_subdirectory(settings.current.install_root_dir, path), + ( + "Refusing to rmrf %q which is outside of the allowed boundary %q. Please report this error at https://github.com/williamboman/nvim-lsp-installer/issues/new" + ):format(path, settings.current.install_root_dir) + ) log.debug("fs: rmrf", path) if vim.in_fast_event() then a.scheduler() @@ -41,6 +49,13 @@ function M.rmrf(path) end end +---@async +---@param path string +function M.unlink(path) + log.debug("fs: unlink", path) + uv.fs_unlink(path) +end + ---@async ---@param path string function M.mkdir(path) -- cgit v1.2.3-70-g09d2