Skip to content

Fix patch panel file expunge feature - #1166

Open
afk11 wants to merge 1 commit into
mainfrom
expunge-pp-fixup
Open

afk11 wants to merge 1 commit into
mainfrom
expunge-pp-fixup

Conversation

@afk11

@afk11 afk11 commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

The patch panel expunge feature is currently not deleting the files associated with the patch panel. When I looked further I noticed a few other areas for improvement

  • Currently the Expunge button is hidden until the patch panel is deactivated, so the form + POST endpoint redirect away if the patch panel is active.
  • Avoid n+1 query problem by rewriting queries. Also move them to the controller, which makes the values assertable in tests
  • POST endpoint rewritten to use transactions, and to only unlink files when the DB operations have completed successfully. Record files which fail to delete in the application logs, and refer use to application logs if there is a delete failure.
  • Use Storage::delete to delete, which builds the filesystem path to the storage directory

minor:

  • added a 'forPatchPanel' scope to the related Models, to save repetition of whereHas logic

Related PR #1167 will provide a command to cleanup leftover files

@afk11
afk11 force-pushed the expunge-pp-fixup branch 3 times, most recently from 9625071 to b687e0b Compare October 28, 2026 08:45
The Patch Panel expunge feature was attempting to delete files with the wrong storage path, and
so left them on the filesystem.

This commit fixes the filesystem path, and adds other improvements:
 - remove unnecessary code (copy paste relic)
 - forbid expunging an active patch panel (must be deactivated first)
 - split file delete from SQL updates, and wrap updates in a transaction
 - for expunge form, query for port count, file count, history count, history file count.. instead of looping and n+1 queries in view
 - add 'scopeForPatchPanel' on related models to avoid repeating whereHas over relations
 - reword deactivate patch panel dialog (don't mention delete)
 - basic feature test of expunge form and expunge handler
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