Add missing user db create

This commit is contained in:
lash 2024-09-05 04:07:45 +01:00
parent 7fc235c84c
commit 3c6585e387
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746

View File

@ -75,20 +75,27 @@ func getHandler(appFlags *asm.FlagParser, rs *resource.DbResource, pe *persist.P
return ussdHandlers, nil return ussdHandlers, nil
} }
func getDataPersister(dbDir string) (*persist.Persister, error) { func getPersister(dbDir string) (*persist.Persister, error) {
err = os.MkdirAll(dp, 0700) err = os.MkdirAll(dp, 0700)
if err != nil { if err != nil {
return nil, fmt.Errorf("state dir create exited with error: %v\n", err) return nil, fmt.Errorf("state dir create exited with error: %v\n", err)
} }
dataStore := gdbmdb.NewGdbmDb() store := gdbmdb.NewGdbmDb()
dataStoreFile := path.Join(dbDir, "states.gdbm") storeFile := path.Join(dbDir, "states.gdbm")
dataStore.Connect(ctx, dataStoreFile) store.Connect(ctx, storeFile)
pr := persist.NewPersister(dataStore) pr := persist.NewPersister(store)
return pr return pr
} }
func getUserdataDb(dbDir string) {
store := gdbmdb.NewGdbmDb()
storeFile := path.Join(dbDir, "userdata.gdbm")
store.Connect(ctx, storeFile)
return store
}
func getResource(resourceDir string) (resource.Resource, error) { func getResource(resourceDir string) (resource.Resource, error) {
store := fsdb.NewFsDb() store := fsdb.NewFsDb()
err = store.Connect(ctx, resourceDir) err = store.Connect(ctx, resourceDir)
@ -141,7 +148,7 @@ func main() {
os.Exit(1) os.Exit(1)
} }
store, err := getUserDb(dataDir) store, err := getUserdataDb(dataDir)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, err.Error()) fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1) os.Exit(1)