checkPosixfsConsistency checks the consistency of the posixfs storage.
(cmd *cobra.Command, cfg *config.Config)
| 155 | |
| 156 | // checkPosixfsConsistency checks the consistency of the posixfs storage. |
| 157 | func checkPosixfsConsistency(cmd *cobra.Command, cfg *config.Config) error { |
| 158 | rootPath, _ := cmd.Flags().GetString("root") |
| 159 | indexesPath := filepath.Join(rootPath, "indexes") |
| 160 | |
| 161 | opt, _ := options.New(map[string]interface{}{ |
| 162 | "root": rootPath, |
| 163 | }) |
| 164 | log := zerolog.Nop() |
| 165 | ignorer = ignore.NewIgnorer(opt, &log) |
| 166 | |
| 167 | _, err := os.Stat(indexesPath) |
| 168 | if err != nil { |
| 169 | if os.IsNotExist(err) { |
| 170 | return fmt.Errorf("consistency check failed: '%s' is not a posixfs root", rootPath) |
| 171 | } |
| 172 | return fmt.Errorf("error accessing '%s': %w", indexesPath, err) |
| 173 | } |
| 174 | |
| 175 | spinnerCfg := yacspin.Config{ |
| 176 | Frequency: 100 * time.Millisecond, |
| 177 | CharSet: yacspin.CharSets[11], |
| 178 | StopCharacter: "✓", |
| 179 | StopColors: []string{"fgGreen"}, |
| 180 | StopFailCharacter: "✗", |
| 181 | StopFailColors: []string{"fgRed"}, |
| 182 | } |
| 183 | |
| 184 | spinner, err = yacspin.New(spinnerCfg) |
| 185 | err = spinner.Start() |
| 186 | if err != nil { |
| 187 | return fmt.Errorf("error creating spinner: %w", err) |
| 188 | } |
| 189 | |
| 190 | checkSpaces(filepath.Join(rootPath, "users")) |
| 191 | spinner.Suffix(" Personal spaces check ") |
| 192 | spinner.StopMessage("completed\n") |
| 193 | spinner.Stop() |
| 194 | |
| 195 | checkSpaces(filepath.Join(rootPath, "projects")) |
| 196 | spinner.Suffix(" Project spaces check ") |
| 197 | spinner.StopMessage("completed") |
| 198 | spinner.Stop() |
| 199 | |
| 200 | if restartRequired { |
| 201 | fmt.Println("\n\n ⚠️ Please restart your openCloud instance to apply changes.") |
| 202 | } |
| 203 | return nil |
| 204 | } |
| 205 | |
| 206 | func checkSpaces(basePath string) { |
| 207 | dirEntries, err := os.ReadDir(basePath) |
no test coverage detected