Skip to content

feat: browse the Recycle Bin, restore items and delete them permanently - #144

Merged
nextestudios merged 2 commits into
mainfrom
feature/26-recycle-bin
Sep 27, 2026
Merged

nextestudios merged 2 commits into
mainfrom
feature/26-recycle-bin

Conversation

@nextestudios

Copy link
Copy Markdown
Owner

Summary

  • RecycleBinLocation (virtual, distinct from PhysicalLocation) and an IRecycleBin contract in Core.
  • WindowsRecycleBin (Infrastructure.Windows/Shell) reads the current user's X:\$Recycle.Bin\<SID> on fixed and removable drives, parsing the $I metadata (v1 and v2) for the original path, size and deletion date.
    • Restore renames $R… back to the original path (same volume), recreating missing folders. It never overwrites: if something is already there it fails with a clear message and the item stays in the bin.
    • The original path comes from disk and is treated as untrusted: it must be fully qualified, already normalized (no ..), on the same drive as the bin and made of valid Windows names. Otherwise the item is listed as blocked and can only be deleted for good. Ids must be a $R… directly inside a known bin folder.
    • Delete permanently removes $R (never following links, reusing the existing permanent-delete helper) and $I.
    • I read $Recycle.Bin directly instead of going through the Shell namespace so restore is deterministic and never shows Windows conflict dialogs. The only Shell API used is the bin icon (SHParseDisplayName + SHGFI_PIDL).
  • Home: a Lixeira place with the Windows icon. Items show the original folder and the deletion date. South/A or North → Restaurar / Excluir permanentemente… / Propriedades. The confirmation always starts on Cancelar. Marking several items works. The footer shows only the actions that work here.

Tests

  • CI unit (journey, in-memory bin): Home → Lixeira, restore, a blocked item can't be restored, permanent delete asks first starting on Cancel, Back doesn't delete.
  • CI Windows integration: a temp file sent to the real Recycle Bin is listed, restored to its (recreated) folder, then deleted for good. A fake bin in a temp dir with crafted $I files checks that relative, .. and other-drive paths are refused, conflicts never overwrite, and ids outside the bin are rejected. The recycle bin icon comes back from the shell.
  • Manual (docs/TESTING.md): Explorer consistency, NTFS USB stick, real controller, Narrator.

Closes #26

🤖 Generated with Claude Code

nextestudios and others added 2 commits September 27, 2026 02:04
- RecycleBinLocation (virtual) and IRecycleBin contract in Core.
- WindowsRecycleBin reads the current user's $Recycle.Bin on fixed and
  removable drives ($I v1/v2 metadata). Restore renames $R back to the
  original path, recreating missing folders and never overwriting; the
  original path is untrusted and must be absolute, normalized, on the same
  drive and made of valid names. Permanent delete never follows links.
- Home lists the bin with the Windows icon (shell PIDL); items show the
  original folder and deletion date. South/A or North offers Restore and
  Delete permanently (confirmation starts on Cancel); marking works.
- Journey test with an in-memory bin; Windows integration tests recycle and
  restore a temp file in the real bin and reject crafted metadata.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nextestudios
nextestudios merged commit 43a10cb into main Sep 27, 2026
1 check passed
@nextestudios
nextestudios deleted the feature/26-recycle-bin branch September 27, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add the Recycle Bin as a browsable location

1 participant