Skip to content

Commit 70337eb

Browse files
committed
fix: gracefully handle trashing file that does not exist
1 parent 349bca8 commit 70337eb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lua/oil/adapters/trash/freedesktop.lua

+6-1
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,13 @@ end
7575
---@param path string
7676
---@return string
7777
local function get_write_trash_dir(path)
78-
local dev = uv.fs_lstat(path).dev
78+
local lstat = uv.fs_lstat(path)
7979
local home_trash = get_home_trash_dir()
80+
if not lstat then
81+
-- If the source file doesn't exist default to home trash dir
82+
return home_trash
83+
end
84+
local dev = lstat.dev
8085
if uv.fs_lstat(home_trash).dev == dev then
8186
return home_trash
8287
end

0 commit comments

Comments
 (0)