Normalize paths
This commit is contained in:
parent
392d0133f7
commit
8f64a349ec
2 changed files with 44 additions and 1 deletions
|
|
@ -65,6 +65,11 @@ func LoadAction(path string) (string, string, error) {
|
|||
}
|
||||
|
||||
func LoadActions(cfg *config.Config) (actions []*Action, err error) {
|
||||
actionsDir, err := filepath.Abs(cfg.ActionsDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = filepath.Walk(cfg.ActionsDir, func(path string, d fs.FileInfo, err error) error {
|
||||
if d.Mode().IsRegular() {
|
||||
hash := sha512.Sum512([]byte(path))
|
||||
|
|
@ -81,11 +86,15 @@ func LoadActions(cfg *config.Config) (actions []*Action, err error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
if apath, err := filepath.Abs(path); err == nil {
|
||||
path = apath
|
||||
}
|
||||
|
||||
actions = append(actions, &Action{
|
||||
Id: hash[:],
|
||||
Name: name,
|
||||
Description: description,
|
||||
Path: path,
|
||||
Path: strings.TrimPrefix(path, actionsDir+"/"),
|
||||
Enabled: d.Mode().Perm()&0111 != 0,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue