Skip to content

Commit 037d991

Browse files
committed
refactor: remove unnecessary temp directory cleanup in diff.lua
1 parent 2befc29 commit 037d991

1 file changed

Lines changed: 0 additions & 21 deletions

File tree

lua/opencode/diff.lua

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ local function export_tree(snapshot_git, tree_hash, callback)
135135
vim.system({ "git", "--git-dir=" .. snapshot_git, "cat-file", "-t", tree_hash }, { text = true }, function(result)
136136
if result.code ~= 0 then
137137
vim.schedule(function()
138-
vim.fn.delete(temp_dir, "rf")
139138
callback("Snapshot object no longer exists (may have been garbage collected): " .. tree_hash, nil)
140139
end)
141140
return
@@ -145,7 +144,6 @@ local function export_tree(snapshot_git, tree_hash, callback)
145144
vim.system({ "git", "--git-dir=" .. snapshot_git, "archive", tree_hash }, { text = false }, function(archive_result)
146145
if archive_result.code ~= 0 then
147146
vim.schedule(function()
148-
vim.fn.delete(temp_dir, "rf")
149147
callback("Failed to archive tree: " .. (archive_result.stderr or ""), nil)
150148
end)
151149
return
@@ -158,7 +156,6 @@ local function export_tree(snapshot_git, tree_hash, callback)
158156
function(tar_result)
159157
vim.schedule(function()
160158
if tar_result.code ~= 0 then
161-
vim.fn.delete(temp_dir, "rf")
162159
callback("Failed to extract archive: " .. (tar_result.stderr or ""), nil)
163160
else
164161
callback(nil, temp_dir)
@@ -206,8 +203,6 @@ local function show_diff(snapshots)
206203
export_tree(snapshot_git, snapshots.last, function(err2, dir2)
207204
if err2 or not dir2 then
208205
vim.notify(err2 or "Failed to export second snapshot", vim.log.levels.ERROR, { title = "opencode" })
209-
-- Clean up first temp dir
210-
vim.fn.delete(dir1, "rf")
211206
return
212207
end
213208

@@ -224,23 +219,7 @@ local function show_diff(snapshots)
224219
end)
225220
if not ok then
226221
vim.notify("Failed to run CodeDiff: " .. tostring(cmd_err), vim.log.levels.ERROR, { title = "opencode" })
227-
vim.fn.delete(dir1, "rf")
228-
vim.fn.delete(dir2, "rf")
229-
return
230222
end
231-
232-
-- Schedule cleanup of temp directories when the tab is closed
233-
local tab_id = vim.api.nvim_get_current_tabpage()
234-
local cleanup_group = vim.api.nvim_create_augroup("OpencodeDiffCleanup", { clear = false })
235-
vim.api.nvim_create_autocmd("TabClosed", {
236-
group = cleanup_group,
237-
pattern = tostring(tab_id),
238-
once = true,
239-
callback = function()
240-
vim.fn.delete(dir1, "rf")
241-
vim.fn.delete(dir2, "rf")
242-
end,
243-
})
244223
end)
245224
end)
246225
end

0 commit comments

Comments
 (0)