feat: 添加打包,修复bug
This commit is contained in:
22
actions.go
22
actions.go
@@ -64,6 +64,28 @@ func executeAction(versionDir string, action Action, index int, backupDir string
|
||||
}
|
||||
return actionCompleteMsg{index: index}
|
||||
}
|
||||
case "new":
|
||||
return func() tea.Msg {
|
||||
absPath := filepath.Join(versionDir, action.Path)
|
||||
if _, err := os.Stat(absPath); err == nil {
|
||||
return actionCompleteMsg{index: index}
|
||||
}
|
||||
if action.IsDir {
|
||||
if err := os.MkdirAll(absPath, 0o755); err != nil {
|
||||
return actionErrorMsg{index: index, err: fmt.Errorf("create dir failed: %w", err)}
|
||||
}
|
||||
} else {
|
||||
if err := os.MkdirAll(filepath.Dir(absPath), 0o755); err != nil {
|
||||
return actionErrorMsg{index: index, err: fmt.Errorf("mkdir failed: %w", err)}
|
||||
}
|
||||
f, err := os.Create(absPath)
|
||||
if err != nil {
|
||||
return actionErrorMsg{index: index, err: fmt.Errorf("create file failed: %w", err)}
|
||||
}
|
||||
f.Close()
|
||||
}
|
||||
return actionCompleteMsg{index: index}
|
||||
}
|
||||
default:
|
||||
return func() tea.Msg {
|
||||
return actionErrorMsg{index: index, err: fmt.Errorf("unknown action type: %s", action.Type)}
|
||||
|
||||
Reference in New Issue
Block a user