-
-
Notifications
You must be signed in to change notification settings - Fork 496
/
fsck.go
35 lines (30 loc) · 988 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 action
import (
"context"
"os"
"path/filepath"
"github.com/justwatchcom/gopass/pkg/config"
"github.com/justwatchcom/gopass/pkg/fsutil"
"github.com/justwatchcom/gopass/pkg/out"
"github.com/urfave/cli"
)
// Fsck checks the store integrity
func (s *Action) Fsck(ctx context.Context, c *cli.Context) error {
// make sure config is in the right place
// we may have loaded it from one of the fallback locations
if err := s.cfg.Save(); err != nil {
return ExitError(ctx, ExitConfig, err, "failed to save config: %s", err)
}
// clean up any previous config locations
oldCfg := filepath.Join(config.Homedir(), ".gopass.yml")
if fsutil.IsFile(oldCfg) {
if err := os.Remove(oldCfg); err != nil {
out.Red(ctx, "Failed to remove old gopass config %s: %s", oldCfg, err)
}
}
// the main work in done by the sub stores
if err := s.Store.Fsck(ctx, c.Args().Get(0)); err != nil {
return ExitError(ctx, ExitFsck, err, "fsck found errors: %s", err)
}
return nil
}