Skip to content

feat: move items to XDG trash with D key (#12) - #608

Open
phaethix wants to merge 11 commits into
dundee:masterfrom
phaethix:feat/move-to-trash
Open

feat: move items to XDG trash with D key (#12)#608
phaethix wants to merge 11 commits into
dundee:masterfrom
phaethix:feat/move-to-trash

Conversation

@phaethix

@phaethix phaethix commented Jul 23, 2026

Copy link
Copy Markdown

Summary

  • Adds interactive D to move selected/marked items into FreeDesktop XDG trash ($XDG_DATA_HOME/Trash, else ~/.local/share/Trash), keeping d = permanent delete and e = empty.
  • Introduces DeleteAction through the TUI delete pipeline and implements remove.MoveItemToTrash with exclusive .trashinfo reservation, cross-device copy fallback, symlink/FIFO-safe handling, and no-clobber rename.
  • Windows builds get a clear unsupported stub; help/--no-delete/archive guards match existing delete behavior.

Closes #12

Test plan

  • go test ./pkg/remove/ ./tui/
  • Cross-compile GOOS=windows / GOOS=linux for pkg/remove
  • Manual: run gdu, press D on a file, confirm it appears under $XDG_DATA_HOME/Trash/{files,info}
  • Manual: name conflict when Trash/files/<name> already exists → lands as <name>.2 without overwriting
  • Manual: ? help shows D; with --no-delete, trash is disabled like delete/empty

Made with Cursor

phaethix and others added 8 commits July 23, 2026 23:31
Introduce DeleteAction to model delete/empty/trash removal modes and
thread it through the TUI delete pipeline ahead of move-to-trash support.

Co-authored-by: Cursor <cursoragent@cursor.com>
Implement XDG trash move on Unix with name-conflict handling and
cross-device fallback; stub on Windows. Includes unit tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Connect ActionMoveToTrash to ui.trasher (default remove.MoveItemToTrash),
bind uppercase D in the main key handler, and document it in help.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Cover D-key trash action via trasher spy and assert help text shows the
trash line enabled and disabled under SetNoDelete.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Use exclusive trashinfo creation and reserved names for concurrent moves, and reject FIFOs and other non-regular files during cross-device copy to avoid hangs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use RENAME_NOREPLACE on Linux and a preflight check elsewhere, and retry with a new reserved name if the destination appears after trashinfo creation.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.38%. Comparing base (fe605ec) to head (1ecc49b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #608      +/-   ##
==========================================
+ Coverage   85.89%   86.38%   +0.49%     
==========================================
  Files          55       59       +4     
  Lines        6329     6487     +158     
==========================================
+ Hits         5436     5604     +168     
+ Misses        689      681       -8     
+ Partials      204      202       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

phaethix and others added 3 commits July 24, 2026 00:19
Make DeleteAction switches list ActionDelete explicitly, name reserveTrashInfo results, and write trashinfo via WriteString.

Co-authored-by: Cursor <cursoragent@cursor.com>
Exercise EXDEV fallback, escape encoding, trashdir defaults, retries, marked/background trash paths, and DeleteAction string helpers.

Co-authored-by: Cursor <cursoragent@cursor.com>
Inject filesystem operations so failure branches can be tested deterministically, and cover archive and confirmation behavior to keep all modified lines exercised.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Delete to recycling bin?

1 participant