1 Commits

3 changed files with 17 additions and 1 deletions

View File

@@ -91,6 +91,14 @@ func New(file string, bucket string, debug bool) (*DB, error) {
return &DB{Debug: debug, Dbfile: file, Bucket: bucket}, nil
}
func (db *DB) Exists() error {
if !common.FileExists(db.Dbfile) {
return fmt.Errorf("db file %s doesn't exist", db.Dbfile)
}
return nil
}
func (db *DB) Open() error {
slog.Debug("opening DB", "dbfile", db.Dbfile)

View File

@@ -30,7 +30,7 @@ import (
"github.com/tlinden/yadu"
)
var Version string = "v0.3.1"
var Version string = "v0.3.2"
type BucketConfig struct {
Encrypt bool

View File

@@ -107,6 +107,10 @@ func Get(conf *cfg.Config) *cobra.Command {
attr.Key = args[0]
}
if err := conf.DB.Exists(); err != nil {
return err
}
entry, err := conf.DB.Get(&attr)
if err != nil {
return err
@@ -207,6 +211,10 @@ func List(conf *cfg.Config) *cobra.Command {
conf.Mode = "wide"
}
if err := conf.DB.Exists(); err != nil {
return err
}
entries, err := conf.DB.List(&attr, conf.Fulltext)
if err != nil {
return err