diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/mason-core/fs.lua | 8 | ||||
| -rw-r--r-- | lua/mason-core/installer/linker.lua | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lua/mason-core/fs.lua b/lua/mason-core/fs.lua index 3c60cf61..203c96d7 100644 --- a/lua/mason-core/fs.lua +++ b/lua/mason-core/fs.lua @@ -86,6 +86,14 @@ local function make_module(uv) end ---@param path string + ---@param new_path string + ---@param flags table? { excl?: boolean, ficlone?: boolean, ficlone_force?: boolean } + function M.copy_file(path, new_path, flags) + log.debug("fs: copy_file", path, new_path, flags) + uv.fs_copyfile(path, new_path, flags) + end + + ---@param path string ---@param contents string ---@param flags string? Defaults to "w". function M.write_file(path, contents, flags) diff --git a/lua/mason-core/installer/linker.lua b/lua/mason-core/installer/linker.lua index c9a87027..7a1098fb 100644 --- a/lua/mason-core/installer/linker.lua +++ b/lua/mason-core/installer/linker.lua @@ -102,9 +102,9 @@ end ---@param context InstallContext ---@param link_context LinkContext -local function rename(context, link_context) +local function copyfile(context, link_context) return link(context, link_context, function(new_abs_path, target_abs_path) - return Result.pcall(fs.async.rename, target_abs_path, new_abs_path) + return Result.pcall(fs.async.copy_file, target_abs_path, new_abs_path, { excl = true }) end) end @@ -138,8 +138,8 @@ function M.link(context) return Result.try(function(try) if platform.is.win then try(win_bin_wrapper(context)) - try(rename(context, LinkContext.SHARE)) - try(rename(context, LinkContext.OPT)) + try(copyfile(context, LinkContext.SHARE)) + try(copyfile(context, LinkContext.OPT)) else try(symlink(context, LinkContext.BIN)) try(symlink(context, LinkContext.SHARE)) |
