aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2025-11-14 04:20:19 +0100
committerGitHub <noreply@github.com>2025-11-14 04:20:19 +0100
commit57e5a8addb8c71fb063ee4acda466c7cf6ad2800 (patch)
tree0f89367f2939fc2806c56f91460da86c886db79a
parentfix(installer): attempt to recover from known fs error while finalizing insta... (diff)
downloadmason-main.tar
mason-main.tar.gz
mason-main.tar.bz2
mason-main.tar.lz
mason-main.tar.xz
mason-main.tar.zst
mason-main.zip
fix(installer): update cwd after uv_fs_rename() was successful (#2033)HEADmain
Also moves to fs.sync calls over fs.async to avoid unnecessary async coroutine overhead.
-rw-r--r--lua/mason-core/installer/context/init.lua16
1 files changed, 8 insertions, 8 deletions
diff --git a/lua/mason-core/installer/context/init.lua b/lua/mason-core/installer/context/init.lua
index e0150e18..9af95f80 100644
--- a/lua/mason-core/installer/context/init.lua
+++ b/lua/mason-core/installer/context/init.lua
@@ -86,19 +86,19 @@ function InstallContext:promote_cwd()
-- 2. Prepare for renaming cwd to destination
if platform.is.unix then
-- Some Unix systems will raise an error when renaming a directory to a destination that does not already exist.
- fs.async.mkdir(install_path)
+ fs.sync.mkdir(install_path)
end
- -- 3. Update cwd
- self.cwd:set(install_path)
- -- 4. Move the cwd to the final installation directory
- local rename_success, rename_err = pcall(fs.async.rename, cwd, install_path)
+ -- 3. Move the cwd to the final installation directory
+ local rename_success, rename_err = pcall(fs.sync.rename, cwd, install_path)
if not rename_success then
-- On some file systems, we cannot create the directory before renaming. Therefore, remove it and then rename.
log.trace("Call to uv_fs_rename() while promoting cwd failed.", rename_err)
- fs.async.rmdir(install_path)
- assert(fs.async.dir_exists(cwd), "Current working directory no longer exists after retrying uv_fs_rename().")
- fs.async.rename(cwd, install_path)
+ fs.sync.rmdir(install_path)
+ assert(fs.sync.dir_exists(cwd), "Current working directory no longer exists after retrying uv_fs_rename().")
+ fs.sync.rename(cwd, install_path)
end
+ -- 4. Update cwd
+ self.cwd:set(install_path)
end
---@param rel_path string The relative path from the current working directory to change cwd to. Will only restore to the initial cwd after execution of fn (if provided).