Skip to content

Add trash bin size reporting to disk usage output#27

Merged
AzisK merged 1 commit intomainfrom
Add-trash-bin-size-reporting-to-disk-usage-output
Nov 30, 2025
Merged

Add trash bin size reporting to disk usage output#27
AzisK merged 1 commit intomainfrom
Add-trash-bin-size-reporting-to-disk-usage-output

Conversation

@AzisK
Copy link
Copy Markdown
Owner

@AzisK AzisK commented Nov 30, 2025

Introduced a get_trash_path() helper to detect the OS-specific trash/recycle bin location and added logic in main() to display the size of the trash bin. The output now warns users if the trash exceeds 1GB and handles permission or missing path cases gracefully.

Introduced a get_trash_path() helper to detect the OS-specific trash/recycle bin location and added logic in main() to display the size of the trash bin. The output now warns users if the trash exceeds 1GB and handles permission or missing path cases gracefully.
@github-actions
Copy link
Copy Markdown

⸜(。˃ ᵕ ˂ )⸝♡ Thank you for opening this Pull Request, AzisK!

( ˶°ㅁ°) !! It's Trivia Time!

Here are 3 trivia questions to keep you entertained while CI runs.
(Feel free to demonstrate your knowledge and reply!)

🧩 Q1: In the video game "Team Fortress 2", which class is able to double jump?

A) Engineer
B) Spy
C) Pyro
D) Scout

🧩 Q2: Which is NOT a book in the Harry Potter Series?

A) The House Elf
B) The Deathly Hallows
C) The Prisoner of Azkaban
D) The Chamber of Secrets

🧩 Q3: In "Kingdom Hearts", who abducts Jasmine in the Lamp Chamber?

A) Riku
B) Riku Replica
C) Xaldin
D) Captain Hook

You got this! Remember, every bug is just a feature in disguise.

@github-actions
Copy link
Copy Markdown

This is an excellent pull request! You've introduced a highly useful feature that provides users with additional insights into their disk usage by incorporating trash bin size reporting. Here’s a detailed review of the changes:


Strengths:

  1. Well-Documented Helper Function:

    • The function has a concise docstring clearly explaining its purpose (). Great use of as the return type hint—this is an excellent use of type hints.
  2. Cross-Platform Considerations:

    • The logic in to handle different OS-specific paths is well-written, and the distinction between , , and is appropriately handled ().
  3. Graceful Error Handling:

    • You're carefully handling edge cases such as:
      • Non-existent trash paths ().
      • Lack of read permissions using ().
      • Potential during traversal ().
    • This ensures that the program won’t unexpectedly crash regardless of the user environment, which improves robustness.
  4. User Notification:

    • Adding a warning message when trash exceeds 1GB () is an excellent touch. It's thoughtful to consider usability and inform users about potentially reclaimable space.
  5. Integration in Output:

    • Adding the trash size output seamlessly into the existing output format (e.g., between disk space info and scanning command) maintains readability and comprehensibility for users.

Suggestions for Improvement:

  1. Control over Trash Size Threshold:

    • Hardcoding the warning threshold of (1GB) () limits flexibility. Consider exposing this as an optional argument with a reasonable default (e.g., ), so users can customize it.
  2. Consider Localization for Messages:

    • Messages like , , and are user-facing. It might be worth extracting these strings for easier future localization support.
  3. Duplicate Access Check:

    • The call to () is immediately followed by a try-except block. Since the block already verifies access, the call might be redundant. Simplifying to just the block can improve performance slightly, especially for trash directories with many files. For example:
  4. Potential Inefficiency in Large Trash Folders:

    • Scanning the trash folder to calculate its size () could be time-consuming for large directories. Consider notifying the user with a message like before performing the scan to set expectations.
  5. Improve Accuracy of Trash Path on Windows:

    • On Windows, using with just might not always locate the correct trash folders if there are additional drives. You can refine this by checking all drives or parsing the output for more accurate detection.

Additional Kudos:

  • Code Readability:

    • The code is clean, structured, and legible. Each check and operation is clearly delineated, making it easy to understand what each block is doing.
  • Minimal Changes to Codebase:

    • The modification integrates seamlessly without introducing unnecessary additional complexity.
  • Backward Compatibility:

    • Great job ensuring that this new feature doesn’t impact users on unsupported or less-common OS environments (e.g., garbage output on BSD or missing paths)—very thoughtful.

Suggested Future Enhancements (Not a blocker for this PR):

  1. Modularize Trash Path Detection:

    • The logic in is great but could eventually evolve into a standalone reusable utility module or class, especially if more OS-specific paths need to be accommodated (e.g., snap or flatpak trash paths on Linux).
  2. Testing:

    • If not already, consider adding test cases to validate the various paths handled by , permission scenarios, and large trash size threshold logic. Python’s could help simulate different system responses.

Closing Remarks:

Well done on implementing an impactful feature in a minimal and efficient way! The code is solid, clean, and demonstrates excellent care for user experience by gracefully handling failure cases. With a few minor adjustments, it will be even better. Keep up the fantastic work—you’re making users’ lives easier, one disk cleanup at a time! 🚀

@github-actions
Copy link
Copy Markdown

🎉 All tests passed! Here's a dog for you! 🐶

Dog

@AzisK AzisK merged commit 7e4515a into main Nov 30, 2025
34 checks passed
@AzisK AzisK deleted the Add-trash-bin-size-reporting-to-disk-usage-output branch January 11, 2026 12:40
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.

1 participant