aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/core/fs.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-04-21 12:09:59 +0200
committerGitHub <noreply@github.com>2022-04-21 12:09:59 +0200
commitb68fcc6bb2c770495ff8e2508c06dfdd49abcc80 (patch)
treedf7c71efb59958deb21a18eeccf3e3c43c4cd704 /lua/nvim-lsp-installer/core/fs.lua
parentrun autogen_metadata.lua (diff)
downloadmason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.gz
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.bz2
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.lz
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.xz
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.zst
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.zip
chore: refactor remaining installers to async impl (#616)
Diffstat (limited to 'lua/nvim-lsp-installer/core/fs.lua')
-rw-r--r--lua/nvim-lsp-installer/core/fs.lua15
1 files changed, 15 insertions, 0 deletions
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()
@@ -43,6 +51,13 @@ 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)
log.debug("fs: mkdir", path)
uv.fs_mkdir(path, 493) -- 493(10) == 755(8)