| 260 | } |
| 261 | |
| 262 | func (a *App) SaveProjectAs() error { |
| 263 | a.mu.Lock() |
| 264 | if a.ActiveScan { |
| 265 | a.mu.Unlock() |
| 266 | return fmt.Errorf("cannot save project during an active debug session") |
| 267 | } |
| 268 | if a.ProjectData.ModsDir == "" { |
| 269 | a.mu.Unlock() |
| 270 | return fmt.Errorf("no mod folder selected") |
| 271 | } |
| 272 | a.mu.Unlock() |
| 273 | |
| 274 | filePath, err := wailsRuntime.SaveFileDialog(a.ctx, wailsRuntime.SaveDialogOptions{ |
| 275 | Title: "Save Project As", |
| 276 | DefaultFilename: "project.json", |
| 277 | Filters: []wailsRuntime.FileFilter{ |
| 278 | {DisplayName: "JSON Files", Pattern: "*.json"}, |
| 279 | }, |
| 280 | }) |
| 281 | if err != nil { |
| 282 | return err |
| 283 | } |
| 284 | if filePath == "" { |
| 285 | return fmt.Errorf("save cancelled") |
| 286 | } |
| 287 | |
| 288 | if err := a.saveToFile(filePath); err != nil { |
| 289 | return err |
| 290 | } |
| 291 | |
| 292 | a.mu.Lock() |
| 293 | a.ProjectFilePath = filePath |
| 294 | a.mu.Unlock() |
| 295 | return nil |
| 296 | } |
| 297 | |
| 298 | func (a *App) saveToFile(filePath string) error { |
| 299 | a.mu.Lock() |