Files
backend/internal/skill/fs.go

31 lines
710 B
Go

package skill
import (
"errors"
"io/fs"
"os"
"path/filepath"
)
// mkdirAll wraps os.MkdirAll so the manager can swap implementations or add
// permission handling in one place.
func mkdirAll(path string) error {
return os.MkdirAll(path, 0o755)
}
// removeIfExists deletes a path, treating "not found" as success. Any other
// error is returned.
func removeIfExists(path string) error {
err := os.Remove(path)
if err == nil || errors.Is(err, fs.ErrNotExist) {
return nil
}
return err
}
// appDir returns the absolute directory holding an app's skills. Not exported;
// used internally when bulk-removing.
func (m *Manager) appDir(appSlug string) string {
return filepath.Join(m.Root, appSlug)
}