Skip to content

Commit

Permalink
fix: synchronize all luarocks CLI invocations (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Jul 14, 2024
1 parent 4ae93ef commit 4a9c276
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lua/rocks/luarocks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ local nio = require("nio")
---@field servers? server_url[] | only_server_url
---@field synchronized? boolean Whether to wait for and acquire a lock (recommended for file system IO, default: `true`)

-- NOTE: We cannot share the semaphore with operations.helpers, or it would deadlock
local semaphore = nio.control.semaphore(1)

--- --only-server if `servers` is a `string`, otherwise --server for each element
Expand All @@ -52,7 +53,7 @@ end
luarocks.cli = nio.create(function(args, on_exit, opts)
opts = opts or {}
---@cast opts LuarocksCliOpts
opts.synchronized = opts.synchronized ~= nil and opts.synchronized or false
opts.synchronized = opts.synchronized ~= nil and opts.synchronized or true
-- Make sure no operations are aborted on nvim exit
opts.detach = true
local on_exit_wrapped = vim.schedule_wrap(function(sc)
Expand Down Expand Up @@ -117,7 +118,10 @@ luarocks.search_all = nio.create(function(callback, opts)
luarocks.cli(cmd, function(obj)
---@cast obj vim.SystemCompleted
future.set(obj)
end, { text = true, synchronized = false, servers = opts and opts.servers or constants.ALL_SERVERS })
end, {
text = true,
servers = opts and opts.servers or constants.ALL_SERVERS,
})
---@type vim.SystemCompleted
local obj = future.wait()
local result = obj.stdout
Expand Down

0 comments on commit 4a9c276

Please sign in to comment.