Skip to content

(feat) add Discord cache category to junk cleaner#24

Merged
Vortrix5 merged 1 commit into
Vortrix5:mainfrom
avatGit:feat/discord-cache
Jun 15, 2026
Merged

(feat) add Discord cache category to junk cleaner#24
Vortrix5 merged 1 commit into
Vortrix5:mainfrom
avatGit:feat/discord-cache

Conversation

@avatGit

@avatGit avatGit commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR addresses the issue regarding Discord's large Chromium-style cache accumulation. It adds a new dedicated junk category discord-cache that identifies and targets safe-to-clear cache directories for Discord and its alternative release channels (PTB and Canary), while strictly preserving user session and login data.
Closes #3

Safety checklist

Sifty deletes files, so every PR keeps these promises:

  • pytest is green, including tests/test_safety.py
  • No new direct deletions (os.remove, shutil.rmtree, Path.unlink); everything goes through safety.trash()
  • New destructive paths default to dry-run and ask before applying
  • New core functions have a matching test

Notes for the reviewer

  • Scope: The discord-cache category safely covers standard Discord, Discord PTB, and Discord Canary by looking at their respective directories in %APPDATA%.
  • Targeted directories: It only targets Cache, Code Cache, and GPUCache subdirectories.
  • Safety Carve-out: Vital user session data (such as Local Storage) is strictly left untouched to ensure users are never logged out of their accounts after a cleanup.
  • Testing: A comprehensive sandbox test has been added to tests/test_junk.py to validate flavor discovery and ensure session folders are never included in the roots.
  • Manual Test: I installed and tested this implementation locally with my own Discord client; the script successfully detected and staged the cache directories for deletion during the dry-run, and my account session remained perfectly active and unaffected afterwards.

@github-actions

Copy link
Copy Markdown

Thanks for your first pull request to Sifty! A couple of things that help it land quickly: Sifty deletes files, so all deletion must go through safety.trash() and destructive paths default to dry-run. Please make sure pytest is green (especially tests/test_safety.py) and that the PR title starts with a type tag like (feat) or (fix). See CONTRIBUTING.md for the full checklist. A maintainer will review shortly.

@github-actions github-actions Bot added area: core Core engine tests Test suite labels Jun 14, 2026
@avatGit avatGit changed the title feat: add Discord cache category to junk cleaner (feat) add Discord cache category to junk cleaner Jun 14, 2026

@Vortrix5 Vortrix5 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition, and the safety side is right. It only builds cache roots, deletion still goes through trash(), and session data (Local Storage etc.) is left untouched. Confirmed the test passes locally.

One thing before this can merge: it doesn't pass lint, so CI is red. ruff check (what CI runs) flags 8 trailing-whitespace and missing-newline issues across both files. ruff check --fix clears all but one. The blank line inside the docstring at junk.py:77 needs its whitespace removed by hand. Run that, re-push, and I'm happy to merge.

Minor, take it or leave it: the other cache-root helpers read env vars through the _env_path() helper rather than os.environ directly, worth matching for consistency.

@avatGit

avatGit commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Nice addition, and the safety side is right. It only builds cache roots, deletion still goes through trash(), and session data (Local Storage etc.) is left untouched. Confirmed the test passes locally.

One thing before this can merge: it doesn't pass lint, so CI is red. ruff check (what CI runs) flags 8 trailing-whitespace and missing-newline issues across both files. ruff check --fix clears all but one. The blank line inside the docstring at junk.py:77 needs its whitespace removed by hand. Run that, re-push, and I'm happy to merge.

Minor, take it or leave it: the other cache-root helpers read env vars through the _env_path() helper rather than os.environ directly, worth matching for consistency.

Thanks for the review!

I've updated the unit test with a robust mock for _env_path .

I also switched to _env_path("APPDATA") as suggested, i cleared trailing whitespaces/docstring errors, and verified that both ruff check . and pytest succed.

@Vortrix5 Vortrix5 merged commit 00f7a2a into Vortrix5:main Jun 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Core engine tests Test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Discord cache as a junk category

2 participants