package app import ( "fmt" "os" "path/filepath" "strings" ) func cleanableRootChildren(root, policy string) (string, []string, error) { rootAbs, exists, err := validateCleanRoot(root, policy) if err != nil { return "", nil, err } if !exists { return rootAbs, nil, nil } entries, err := os.ReadDir(rootAbs) if err != nil { return "", nil, fmt.Errorf("cleanup policy %s: read root %q: %w", policy, rootAbs, err) } out := make([]string, 0, len(entries)) for _, entry := range entries { path := filepath.Join(rootAbs, entry.Name()) info, err := os.Lstat(path) if err != nil { return "", nil, fmt.Errorf("cleanup policy %s: stat child %q: %w", policy, path, err) } if info.Mode()&os.ModeSymlink != 0 { return "", nil, fmt.Errorf("cleanup policy %s: refusing to delete symlink path %q", policy, path) } out = append(out, path) } return rootAbs, out, nil } func validateScopedFile(root, target, policy string) (scopedDir, error) { return validateScopedTarget(root, target, policy, false) } func cleanIsFlac(path string) bool { return strings.EqualFold(filepath.Ext(path), ".flac") }