Skip to content

fix(maintenance): harden cache cleanup against broad deletion and improve file organizer safety - #31

Merged
ashishsinghbora merged 1 commit into
mainfrom
fix/file-cleanup-safety
Sep 24, 2026
Merged

ashishsinghbora merged 1 commit into
mainfrom
fix/file-cleanup-safety

Conversation

@ashishsinghbora

Copy link
Copy Markdown
Owner

Summary

cleanup-cache.sh

  • Removed redundant duplicated code block and fixed typo in redirect syntax (dev/null -> /dev/null).
  • Eliminated unconditional broad rm -rf /tmp deletion to protect active user sessions, sockets, and locks.
  • Added user confirmation prompt, -n / --dry-run inspection, and -y / --yes auto-confirmation.
  • Added cache inspection and safe cleanup for user thumbnail cache (~/.cache/thumbnails) and user trash.
  • Added comprehensive cache usage detection across pacman, apt, dnf, zypper, apk, and systemd journal.

file-organizer.sh

  • Added guards preventing accidental execution on root / and $HOME root.
  • Safely skips symbolic links to prevent breaking relative links or dangling targets.
  • Preserves hidden files, files without extensions, and avoids overwriting existing destination files.
  • Added markdown (.md) to documents and expanded archive/audio formats.

Verification

  • Tested dry-run and live file organization with spaces, Unicode characters, collisions, hidden files, and symlinks.
  • Tested dry-run and live cache cleanup with mock temporary HOME.
  • Verified ShellCheck passes without warnings.
  • Verified test suite passes.

@ashishsinghbora ashishsinghbora left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Code review: verified safe user cache cleanup replacing broad /tmp deletion, verified symlink and collision handling in file organizer, and confirmed all tests pass.

@ashishsinghbora
ashishsinghbora merged commit 5181add into main Sep 24, 2026
1 check passed
@ashishsinghbora
ashishsinghbora deleted the fix/file-cleanup-safety branch September 24, 2026 18:04
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