Remove empty directories after mod update file deletion#250
Merged
ManlyMarco merged 6 commits intomasterfrom Apr 10, 2026
Merged
Remove empty directories after mod update file deletion#250ManlyMarco merged 6 commits intomasterfrom
ManlyMarco merged 6 commits intomasterfrom
Conversation
Agent-Logs-Url: https://github.com/IllusionMods/KKManager/sessions/55d8ec97-441e-4357-b271-bea6d6e85151 Co-authored-by: ManlyMarco <39247311+ManlyMarco@users.noreply.github.com>
…pty dir cleanup Agent-Logs-Url: https://github.com/IllusionMods/KKManager/sessions/55d8ec97-441e-4357-b271-bea6d6e85151 Co-authored-by: ManlyMarco <39247311+ManlyMarco@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove empty directories during mod update
Remove empty directories after mod update file deletion
Apr 10, 2026
ManlyMarco
reviewed
Apr 10, 2026
Collaborator
ManlyMarco
left a comment
There was a problem hiding this comment.
@copilot Handle DirectoryNotFoundException and SecurityException as well
…dir cleanup Agent-Logs-Url: https://github.com/IllusionMods/KKManager/sessions/cf293b54-a97e-489f-af9d-569067a4cf69 Co-authored-by: ManlyMarco <39247311+ManlyMarco@users.noreply.github.com>
Contributor
Author
ManlyMarco
reviewed
Apr 10, 2026
ManlyMarco
approved these changes
Apr 10, 2026
ManlyMarco
reviewed
Apr 10, 2026
Collaborator
ManlyMarco
left a comment
There was a problem hiding this comment.
@copilot Build error: D:\a\KKManager\KKManager\src\KKManager.Updater\Data\UpdateItem.cs(132,72): error CS1061: 'IEnumerable' does not contain a definition for 'Any' and no accessible extension method 'Any' accepting a first argument of type 'IEnumerable' could be found (are you missing a using directive or an assembly reference?) [D:\a\KKManager\KKManager\src\KKManager.Updater\KKManager.Updater.csproj]
Agent-Logs-Url: https://github.com/IllusionMods/KKManager/sessions/883b49ff-a042-4899-a501-6894af240155 Co-authored-by: ManlyMarco <39247311+ManlyMarco@users.noreply.github.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When mod updates remove files, their parent directories may be left behind as empty folders. This adds cleanup logic to walk up the directory tree and remove empty directories after each file deletion.
Changes
UpdateItem.Update(): In the delete-only path (RemoteFile == null), after the target file is removed, walks upTargetPath.Directoryand deletes any empty directories until hitting a non-empty dir or the game roottryblock to handle concurrent filesystem modificationsIOException,UnauthorizedAccessException) — logs and breaks on failureInstallDirectoryHelper.GameDirectoryto avoid over-deletion