fix(curl): show error when XDG_RUNTIME_DIR not writable (#785)
This commit is contained in:
parent
75867597f2
commit
e3df3b479f
@ -1,5 +1,6 @@
|
||||
local api = vim.api
|
||||
local fn = vim.fn
|
||||
local uv = vim.uv
|
||||
|
||||
local curl = require("plenary.curl")
|
||||
|
||||
@ -160,7 +161,25 @@ M.stream = function(opts)
|
||||
end
|
||||
end)
|
||||
end,
|
||||
on_error = function()
|
||||
on_error = function(err)
|
||||
if err.exit == 23 then
|
||||
local xdg_runtime_dir = os.getenv("XDG_RUNTIME_DIR")
|
||||
if fn.isdirectory(xdg_runtime_dir) == 0 then
|
||||
Utils.error(
|
||||
"$XDG_RUNTIME_DIR="
|
||||
.. xdg_runtime_dir
|
||||
.. " is set but does not exist. curl could not write output. Please make sure it exists, or unset.",
|
||||
{ title = "Avante" }
|
||||
)
|
||||
elseif not uv.fs_access(xdg_runtime_dir, "w") then
|
||||
Utils.error(
|
||||
"$XDG_RUNTIME_DIR="
|
||||
.. xdg_runtime_dir
|
||||
.. " exists but is not writable. curl could not write output. Please make sure it is writable, or unset.",
|
||||
{ title = "Avante" }
|
||||
)
|
||||
end
|
||||
end
|
||||
active_job = nil
|
||||
completed = true
|
||||
cleanup()
|
||||
|
Loading…
x
Reference in New Issue
Block a user