Initial commit: CarrotAssistant backend (Go + Gin + SQLite, OpenAI-compatible agent runtime)
This commit is contained in:
30
internal/skill/fs.go
Normal file
30
internal/skill/fs.go
Normal file
@@ -0,0 +1,30 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user