Skip to content

Commit ad47a87

Browse files
authored
feat(fs_actions): check file existence on fs_open error (#912)
1 parent 8a60083 commit ad47a87

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lua/neo-tree/sources/filesystem/lib/fs_actions.lua

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,16 @@ M.create_node = function(in_directory, callback, using_root_directory)
365365
+ loop.constants.O_TRUNC
366366
local fd = loop.fs_open(destination, "w", open_mode)
367367
if not fd then
368-
api.nvim_err_writeln("Could not create file " .. destination)
369-
return
368+
if not loop.fs_stat(destination) then
369+
api.nvim_err_writeln("Could not create file " .. destination)
370+
return
371+
else
372+
log.warn("Failed to complete file creation of " .. destination)
373+
end
374+
else
375+
loop.fs_chmod(destination, 420)
376+
loop.fs_close(fd)
370377
end
371-
loop.fs_chmod(destination, 420)
372-
loop.fs_close(fd)
373378
end
374379

375380
vim.schedule(function()

0 commit comments

Comments
 (0)