-
-
Notifications
You must be signed in to change notification settings - Fork 548
Fix incomplete plugin directory deletion on uninstall #4250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Co-authored-by: Jack251970 <[email protected]>
Co-authored-by: Jack251970 <[email protected]>
Refactored the process for recreating the marker file when a plugin directory is not fully deleted. Removed unnecessary try-catch and nested checks, now directly checking for file existence and creating it if missing. This streamlines the code and removes redundant error handling.
…letion Fix incomplete plugin directory deletion on uninstall
This comment has been minimized.
This comment has been minimized.
📝 WalkthroughWalkthroughReplaces the previous direct directory deletion with a new robust deletion routine (FilesFolders.TryDeleteDirectoryRobust). PluginConfig now uses that routine, logs a warning and writes a plugin-delete marker if deletion is incomplete. PluginManager removes the marker on successful install. Adds tests for the new utility. Changes
Sequence DiagramsequenceDiagram
participant PC as PluginConfig
participant FD as FilesFolders.TryDeleteDirectoryRobust
participant FS as FileSystem
participant DL as DataLocation
participant PA as PublicApi
PC->>FD: Request delete directory(path)
FD->>FS: Enumerate files & subdirs
loop per-file retries
FD->>FS: Remove read-only attribute (if set)
FD->>FS: Attempt file delete
alt delete succeeds
FS-->>FD: file removed
else retryable failure
FD-->>FS: wait retryDelay and retry
else non-retryable failure
FS-->>FD: failure
end
end
FD->>FS: Delete empty subdirs (deep → shallow)
FD->>FS: Delete root directory
alt all deleted
FS-->>FD: success
FD-->>PC: return true
else partial/failure
FS-->>FD: partial/failure
FD-->>PC: return false
end
alt deletion returned false
PC->>DL: Create PluginDeleteFile marker (if missing)
PC->>PA: LogWarn about deferred deletion
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request enhances plugin directory deletion in Flow Launcher by introducing a robust deletion mechanism that handles locked and read-only files more gracefully. The changes ensure that incomplete deletions are retried on subsequent application startups.
Changes:
- Added
TryDeleteDirectoryRobustmethod with retry logic for handling locked/read-only files during deletion - Updated plugin configuration to use the new robust deletion method and implement marker file recreation for retry logic
- Added comprehensive unit tests covering various deletion scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs | Implements new TryDeleteDirectoryRobust method with retry logic and read-only file handling |
| Flow.Launcher.Core/Plugin/PluginConfig.cs | Updates deletion logic to use robust method, adds marker file recreation and warning logging for incomplete deletions |
| Flow.Launcher.Test/FilesFoldersTest.cs | Adds unit tests for various deletion scenarios including empty directories, files, nested structures, and read-only files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 3 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs">
<violation number="1" location="Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs:209">
P2: `Directory.Delete` will throw an `IOException` if the directory itself is marked ReadOnly. The current implementation clears the ReadOnly attribute for files but not for directories. If a directory is ReadOnly, this method will permanently fail to delete it, causing infinite retries on subsequent startups.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Simplified the warning log when a directory is not fully deleted, removing extra details about remaining files and retrying deletion. Marker file recreation logic is unchanged.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@Flow.Launcher.Core/Plugin/PluginManager.cs`:
- Around line 934-944: The log message in the catch for deleting the plugin
marker file uses a duplicated word ("Failed to delete delete mark file"); update
the message to something like "Failed to delete marker file" and include the
plugin path for diagnostics; modify the PublicApi.Instance.LogException call in
the try/catch around File.Delete (referencing ClassName, markerFilePath,
newPluginPath and DataLocation.PluginDeleteFile) to log the corrected message
and append newPluginPath (or markerFilePath) so the exception includes the
file/path context.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. Forbidden patterns 🙅 (1)In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves. These forbidden patterns matched content: PatternIf the flagged items are 🤯 false positivesIf items relate to a ...
|
Test: