| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | |
| 6 | "reasonix/internal/config" |
| 7 | "reasonix/internal/pluginpkg" |
| 8 | ) |
| 9 | |
| 10 | type StorageSettingsView struct { |
| 11 | DefaultWorkspace string `json:"defaultWorkspace"` |
| 12 | StatePath string `json:"statePath"` |
| 13 | CachePath string `json:"cachePath"` |
| 14 | ExtensionsPath string `json:"extensionsPath"` |
| 15 | } |
| 16 | |
| 17 | func (a *App) StorageSettings() StorageSettingsView { |
| 18 | return StorageSettingsView{ |
| 19 | DefaultWorkspace: storageDefaultWorkspace(), |
| 20 | StatePath: config.MemoryUserDir(), |
| 21 | CachePath: config.CacheDir(), |
| 22 | ExtensionsPath: pluginpkg.PluginsDir(config.ReasonixHomeDir()), |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | func storageDefaultWorkspace() string { |
| 27 | if workspace := loadWorkspace(); workspace != "" { |
| 28 | if info, err := os.Stat(workspace); err == nil && info.IsDir() { |
| 29 | return workspace |
| 30 | } |
| 31 | } |
| 32 | workspace, _ := os.Getwd() |
| 33 | return workspace |
| 34 | } |
| 35 |