feat(storage): rename snapraid_content to snapraid_conf; clarify conf vs content file; add auto-detect and conf viewer

This commit is contained in:
2026-07-07 01:17:55 -04:00
parent 047f0f5c09
commit 599af5a828
11 changed files with 143 additions and 42 deletions
+11 -11
View File
@@ -8,17 +8,17 @@ import (
)
type SnapraidConfig struct {
Content string
DataDirs []string
Conf string
DataDirs []string
ParityDir string
ScrubPlan int
}
func BuildSnapraidArgs(kind string, cfg SnapraidConfig) ([]string, error) {
if cfg.Content == "" {
return nil, fmt.Errorf("snapraid content file is required")
if cfg.Conf == "" {
return nil, fmt.Errorf("snapraid conf file is required")
}
args := []string{"snapraid", "-c", cfg.Content}
args := []string{"snapraid", "-c", cfg.Conf}
switch kind {
case "snapraid_diff":
args = append(args, "diff")
@@ -34,16 +34,16 @@ func BuildSnapraidArgs(kind string, cfg SnapraidConfig) ([]string, error) {
return args, nil
}
func ValidateSnapraidContent(content string) error {
if content == "" {
return fmt.Errorf("snapraid content file is required")
func ValidateSnapraidConf(conf string) error {
if conf == "" {
return fmt.Errorf("snapraid conf file is required")
}
info, err := os.Stat(content)
info, err := os.Stat(conf)
if err != nil {
return fmt.Errorf("snapraid content %s: %w", content, err)
return fmt.Errorf("snapraid conf %s: %w", conf, err)
}
if info.IsDir() {
return fmt.Errorf("snapraid content %s: is a directory, not a file", content)
return fmt.Errorf("snapraid conf %s: is a directory, not a file", conf)
}
return nil
}