Files
Dominik Schulz 6a0324a2e3 Do not run sync twice on gopass sync w/ autosync (#2321)
* Do not run sync twice on gopass sync w/ autosync

Fixes #2319

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Account for running sync multiple times in the REPL shell

If gopass is invoked as a REPL shell it is reasonable to have
several invocations during the same invocation.

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Fix fsck tests

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Fix golangci-lint issues

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
2022-09-03 11:16:58 +02:00

41 lines
840 B
Go

package leaf
import (
"context"
"strings"
"github.com/gopasspw/gopass/pkg/debug"
)
// Sep is the separator used in lists to separate folders from entries.
var Sep = "/"
// List will list all entries in this store.
func (s *Store) List(ctx context.Context, prefix string) ([]string, error) {
if s.storage == nil || s.crypto == nil {
return nil, nil
}
lst, err := s.storage.List(ctx, prefix)
if err != nil {
return nil, err
}
debug.Log("Listing storage content of %s: %+v", prefix, lst)
out := make([]string, 0, len(lst))
cExt := "." + s.crypto.Ext()
for _, path := range lst {
if !strings.HasSuffix(path, cExt) {
continue
}
path = strings.TrimSuffix(path, cExt)
if s.alias != "" {
path = s.alias + Sep + path
}
out = append(out, path)
}
debug.Log("Leaf store entries: %+v", out)
return out, nil
}