-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(app): delete parent dir after uninstall app #8350
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,6 +100,16 @@ func CheckTaskIsExecuting(name string) error { | |
| return nil | ||
| } | ||
|
|
||
| func CheckResourceTaskIsExecuting(operate, scope string, resourceID uint) bool { | ||
| taskRepo := repo.NewITaskRepo() | ||
| task, _ := taskRepo.GetFirst( | ||
| taskRepo.WithByStatus(constant.StatusExecuting), | ||
| taskRepo.WithResourceID(resourceID), | ||
| taskRepo.WithOperate(operate), | ||
| repo.WithByType(scope)) | ||
| return task.ID != "" | ||
| } | ||
|
|
||
| func NewTask(name, operate, taskScope, taskID string, resourceID uint) (*Task, error) { | ||
| if taskID == "" { | ||
| taskID = uuid.New().String() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Overall, there isn't significant irregularity or potential issue detected in this update snippet from April 2023. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,9 +89,10 @@ const installExtension = async (row: Runtime.SupportExtension) => { | |
| try { | ||
| await InstallPHPExtension(req); | ||
| taskLogRef.value.openWithTaskID(req.taskID); | ||
|
|
||
| } catch (error) { | ||
| } finally { | ||
| loading.value = false; | ||
| } catch (error) {} | ||
| } | ||
| }); | ||
| }; | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code seems mostly correct, but here are a few improvements and suggestions:
Here's an optimized version of the function: const installExtension = async (row: Runtime.SupportExtension) => {
try {
await InstallPHPExtension(row.req); // Use PascalCase for req
taskLogRef.value.openWithTaskID(row.req.taskID);
} catch (error) {
console.error('Error installing extension:', error);
} finally {
loading.value = false;
}
};Remember to adjust any other variables or functions in your project to maintain consistency with these guidelines. |
||
|
|
||
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.
The added code to handle empty parent directories is beneficial for maintaining directory structure consistency. Here’s a brief summary of the changes:
import "path/filepath"is added at the top of the file to use functions from this package.Inside the
deleteAppInstallfunction:_ = op.DeleteDir(...).After deleting the child directory (
appDir) within its parent, additional logic is implemented for handling an empty parent directory conditionally:filepath.Dir(appDir).os.ReadDir(parentDir).Optimization Suggestions:
Consistent Error Handling: Ensure consistent error handling across the codebase to maintain reliability and prevent silent failures due to missing imports or unexpected errors.
Avoid Duplicated Code: Review if these checks can be reused elsewhere in the codebase to avoid duplication, potentially improving scalability and maintenance efficiency.
Testing: Consider adding comprehensive tests to cover scenarios where parent directories might remain non-empty after deletions, which could indicate other underlying issues in the system.
By incorporating these optimizations, the overall functionality remains robust while also making the code more reusable and maintainable over time.