Skip to content

fix: clean up empty parent category directory on script deletion#232

Open
tejask011 wants to merge 1 commit into
siddu-k:mainfrom
tejask011:feature/empty-category-cleanup
Open

fix: clean up empty parent category directory on script deletion#232
tejask011 wants to merge 1 commit into
siddu-k:mainfrom
tejask011:feature/empty-category-cleanup

Conversation

@tejask011

Copy link
Copy Markdown

Fixes Issue #231

Description

This pull request resolves the issue where deleting a script left behind an empty category directory on the local filesystem.

Previously, when the last script within a category was deleted, the script file was removed successfully but the now-empty category directory remained under the scripts/ directory. Over time, this could lead to an accumulation of unused empty folders.

With this change, the application now automatically checks the parent category directory after a script deletion. If the directory is empty and is not the root scripts/ directory, it is removed automatically.


Changes Made

Backend Changes

  • Updated the script deletion workflow to perform automatic cleanup of empty category directories.
  • Added safeguards to ensure the root scripts/ directory is never removed.
  • Preserved existing path validation and security checks.

Test Updates

  • Added test coverage for automatic cleanup of empty category folders.
  • Added test coverage to ensure category folders are retained when other scripts still exist.
  • Verified existing deletion-related tests continue to pass.

Testing and Validation

Scenarios Tested

1. Delete Last Script in a Category

  • Created a category containing a single script.
  • Deleted the script.
  • Verified the script file was removed.
  • Verified the empty category directory was automatically deleted.

2. Delete Script While Other Scripts Exist

  • Created a category containing multiple scripts.
  • Deleted one script.
  • Verified the script file was removed.
  • Verified the category directory remained intact because other scripts still existed.

3. Regression Testing

  • Executed the complete test suite.
  • Confirmed all existing tests continue to pass without modification.

Screenshots and Logs

image

No UI changes were introduced as part of this fix.


Checklist

  • No breaking changes
  • Tests added or updated
  • Existing tests pass successfully
  • Documentation updated where necessary
  • Branch is up to date with main
  • Root scripts/ directory remains protected

##close #231

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.

Empty Category Directories Are Not Removed After Deleting the Last Script

1 participant