Skip to content

Commit

Permalink
Follow symlinks (#516)
Browse files Browse the repository at this point in the history
Fixes #514
  • Loading branch information
dominikschulz authored Dec 13, 2017
1 parent 78dddd7 commit 48d5470
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
7 changes: 6 additions & 1 deletion store/sub/fsck.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ func (s *Store) Fsck(ctx context.Context, prefix string) (map[string]uint64, err
countFn := func(t string) {
counts[t]++
}
err = filepath.Walk(s.path, s.mkStoreWalkerFsckFunc(ctx, prefix, storeRec, countFn))

path, err := filepath.EvalSymlinks(s.path)
if err != nil {
return counts, err
}
err = filepath.Walk(path, s.mkStoreWalkerFsckFunc(ctx, prefix, storeRec, countFn))
return counts, err
}

Expand Down
10 changes: 7 additions & 3 deletions store/sub/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ func mkStoreWalkerFunc(alias, folder string, fn func(...string)) func(string, os
if info.IsDir() {
return nil
}
if strings.HasPrefix(info.Name(), ".") {
if path == folder {
return nil
}
if path == folder {
if strings.HasPrefix(info.Name(), ".") {
return nil
}
if path == filepath.Join(folder, GPGID) {
Expand Down Expand Up @@ -56,6 +56,10 @@ func (s *Store) List(prefix string) ([]string, error) {
lst = append(lst, in...)
}

err := filepath.Walk(s.path, mkStoreWalkerFunc(prefix, s.path, addFunc))
path, err := filepath.EvalSymlinks(s.path)
if err != nil {
return lst, err
}
err = filepath.Walk(path, mkStoreWalkerFunc(prefix, path, addFunc))
return lst, err
}
6 changes: 5 additions & 1 deletion store/sub/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ func (s *Store) ListTemplates(prefix string) []string {
lst = append(lst, in...)
}

if err := filepath.Walk(s.path, mkTemplateStoreWalkerFunc(prefix, s.path, addFunc)); err != nil {
path, err := filepath.EvalSymlinks(s.path)
if err != nil {
return lst
}
if err := filepath.Walk(path, mkTemplateStoreWalkerFunc(prefix, path, addFunc)); err != nil {
fmt.Printf("Failed to list templates: %s\n", err)
}

Expand Down

0 comments on commit 48d5470

Please sign in to comment.