forked from gopasspw/gopass
/
convert.go
30 lines (26 loc) · 834 Bytes
/
convert.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
package root
import (
"context"
"github.com/gopasspw/gopass/internal/backend"
"github.com/gopasspw/gopass/pkg/debug"
)
// Convert will try to convert a given mount to a different set of
// backends.
func (r *Store) Convert(ctx context.Context, name string, cryptoBe backend.CryptoBackend, storageBe backend.StorageBackend, move bool) error {
sub, err := r.GetSubStore(name)
if err != nil {
return err
}
debug.Log("converting %s to crypto: %s, rcs: %s, storage: %s", name, cryptoBe, storageBe)
if err := sub.Convert(ctx, cryptoBe, storageBe, move); err != nil {
return err
}
if name == "" {
debug.Log("success. updating root path to %s", sub.Path())
r.cfg.Path = sub.Path()
} else {
debug.Log("success. updating path for %s to %s", name, sub.Path())
r.cfg.Mounts[name] = sub.Path()
}
return r.cfg.Save()
}