mirror of
https://github.com/stablyai/orca.git
synced 2026-10-20 08:03:28 +00:00
test(worktrees): keep no empty trash root when the rename cannot run
This commit is contained in:
@@ -56,8 +56,11 @@ describe('moveWorktreeDirectoryToTrash', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('reports the rename as unavailable when the checkout is missing', async () => {
|
||||
expect(await moveWorktreeDirectoryToTrash(join(scratchDir, 'repo', 'gone'))).toBeUndefined()
|
||||
it('reports the rename as unavailable and leaves no trash root when the checkout is missing', async () => {
|
||||
const worktreePath = join(scratchDir, 'repo', 'gone')
|
||||
|
||||
expect(await moveWorktreeDirectoryToTrash(worktreePath)).toBeUndefined()
|
||||
expect(existsSync(getWorktreeTrashRoot(worktreePath))).toBe(false)
|
||||
})
|
||||
|
||||
async function seededWorktree(name: string): Promise<string> {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// is a metadata operation, and the recursive delete then runs after the IPC has already returned.
|
||||
|
||||
import { randomBytes } from 'node:crypto'
|
||||
import { mkdir, readdir, rename } from 'node:fs/promises'
|
||||
import { mkdir, readdir, rename, rmdir } from 'node:fs/promises'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { removeHostTree } from './host-tree-removal'
|
||||
import { isFolderRepo } from '../shared/repo-kind'
|
||||
@@ -46,6 +46,8 @@ export async function moveWorktreeDirectoryToTrash(
|
||||
`[worktrees] Deferred deletion unavailable for ${worktreePath}; deleting in place`,
|
||||
error
|
||||
)
|
||||
// Leave no empty trash root behind when the rename never happened; rmdir keeps queued entries.
|
||||
await rmdir(trashRoot).catch(() => {})
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user