Skip to content

Commit

Permalink
fix: gracefully handle trashing file that does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Aug 26, 2024
1 parent 349bca8 commit 70337eb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lua/oil/adapters/trash/freedesktop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ end
---@param path string
---@return string
local function get_write_trash_dir(path)
local dev = uv.fs_lstat(path).dev
local lstat = uv.fs_lstat(path)
local home_trash = get_home_trash_dir()
if not lstat then
-- If the source file doesn't exist default to home trash dir
return home_trash
end
local dev = lstat.dev
if uv.fs_lstat(home_trash).dev == dev then
return home_trash
end
Expand Down

0 comments on commit 70337eb

Please # to comment.