forked from gopasspw/gopass
/
fsck.go
35 lines (30 loc) · 847 Bytes
/
fsck.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package root
import (
"context"
"strings"
"github.com/gopasspw/gopass/pkg/out"
multierror "github.com/hashicorp/go-multierror"
)
// Fsck checks all stores/entries matching the given prefix
func (s *Store) Fsck(ctx context.Context, path string) error {
var result error
for alias, sub := range s.mounts {
if sub == nil {
continue
}
if path != "" && !strings.HasPrefix(path, alias+"/") {
continue
}
path = strings.TrimPrefix(path, alias+"/")
out.Debug(ctx, "root.Fsck() - Checking %s", alias)
if err := sub.Fsck(ctx, path); err != nil {
out.Error(ctx, "fsck failed on sub store %s: %s", alias, err)
result = multierror.Append(result, err)
}
}
if err := s.store.Fsck(ctx, path); err != nil {
out.Error(ctx, "fsck failed on root store: %s", err)
result = multierror.Append(result, err)
}
return result
}