Feature/vhs demo (#15)

* add vhs made demo gif

* add support for ANYDB_DB env var

* left one section

* fixed data type bug, added demo gifs, upgraded dependencies

---------

Co-authored-by: Thomas von Dein <tom@vondein.org>
This commit is contained in:
T.v.Dein
2025-02-02 19:42:12 +01:00
committed by GitHub
parent 359d134d6e
commit d794cc8608
17 changed files with 362 additions and 173 deletions

View File

@@ -61,6 +61,24 @@ type DbTag struct {
const BucketData string = "data"
func GetDbFile(file string) string {
if file != "" {
return file
}
file = os.Getenv("ANYDB_DB")
if file != "" {
return file
}
home, err := os.UserHomeDir()
if err != nil {
panic(err)
}
return filepath.Join(home, ".config", "anydb", "default.db")
}
func New(file string, bucket string, debug bool) (*DB, error) {
return &DB{Debug: debug, Dbfile: file, Bucket: bucket}, nil
}
@@ -131,7 +149,7 @@ func (db *DB) List(attr *DbAttr, fulltext bool) (DbEntries, error) {
value := databucket.Get([]byte(entry.Key)) // empty is ok
vc := make([]byte, len(value))
copy(vc, value)
entry.Value = vc
entry.Value = string(vc)
}
var include bool
@@ -326,7 +344,7 @@ func (db *DB) Get(attr *DbAttr) (*DbEntry, error) {
vc := make([]byte, len(value))
copy(vc, value)
entry.Value = vc
entry.Value = string(vc)
return nil
})
@@ -422,7 +440,7 @@ func (db *DB) Import(attr *DbAttr) (string, error) {
}
// write value
err = databucket.Put([]byte(entry.Key), entry.Value)
err = databucket.Put([]byte(entry.Key), []byte(entry.Value))
if err != nil {
return fmt.Errorf("failed to insert data: %w", err)
}
@@ -525,7 +543,7 @@ func (db *DB) Getall(attr *DbAttr) (DbEntries, error) {
vc := make([]byte, len(value))
copy(vc, value)
entry.Value = vc
entry.Value = string(vc)
entries = append(entries, &entry)
return nil

View File

@@ -33,7 +33,7 @@ type DbEntry struct {
Size uint64 `protobuf:"varint,6,opt,name=Size,proto3" json:"Size,omitempty"`
Encrypted bool `protobuf:"varint,7,opt,name=Encrypted,proto3" json:"Encrypted,omitempty"`
Binary bool `protobuf:"varint,8,opt,name=Binary,proto3" json:"Binary,omitempty"`
Value []byte `protobuf:"bytes,9,opt,name=Value,proto3" json:"Value,omitempty"`
Value string `protobuf:"bytes,9,opt,name=Value,proto3" json:"Value,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -124,11 +124,11 @@ func (x *DbEntry) GetBinary() bool {
return false
}
func (x *DbEntry) GetValue() []byte {
func (x *DbEntry) GetValue() string {
if x != nil {
return x.Value
}
return nil
return ""
}
var File_app_dbentry_proto protoreflect.FileDescriptor
@@ -152,7 +152,7 @@ var file_app_dbentry_proto_rawDesc = []byte{
0x28, 0x08, 0x52, 0x09, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x12, 0x16, 0x0a,
0x06, 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x42,
0x69, 0x6e, 0x61, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x09,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x1e, 0x5a, 0x1c, 0x67,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x1e, 0x5a, 0x1c, 0x67,
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x6c, 0x69, 0x6e, 0x64, 0x65,
0x6e, 0x2f, 0x61, 0x6e, 0x79, 0x64, 0x62, 0x2f, 0x61, 0x70, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,

View File

@@ -16,5 +16,5 @@ message DbEntry {
uint64 Size = 6;
bool Encrypted = 7;
bool Binary = 8;
bytes Value = 9;
string Value = 9;
}