mirror of
https://github.com/tinode/chat.git
synced 2025-03-14 10:05:07 +00:00
update tinode-db for the store interface changes
This commit is contained in:
@ -25,7 +25,7 @@ func genDb(data *Data) {
|
||||
}
|
||||
|
||||
// Add authentication record
|
||||
authHandler := store.GetAuthHandler("basic")
|
||||
authHandler := store.Store.GetAuthHandler("basic")
|
||||
authHandler.Init([]byte(`{"add_to_tags": true}`), "basic")
|
||||
|
||||
nameIndex := make(map[string]string, len(data.Users))
|
||||
@ -92,7 +92,7 @@ func genDb(data *Data) {
|
||||
}
|
||||
}
|
||||
// Add authentication record
|
||||
authHandler := store.GetAuthHandler("basic")
|
||||
authHandler := store.Store.GetAuthHandler("basic")
|
||||
passwd := uu.Password
|
||||
if passwd == "(random)" {
|
||||
// Generate random password
|
||||
|
@ -153,7 +153,7 @@ type Data struct {
|
||||
|
||||
// Generate random string as a name of the group topic
|
||||
func genTopicName() string {
|
||||
return "grp" + store.GetUidString()
|
||||
return "grp" + store.Store.GetUidString()
|
||||
}
|
||||
|
||||
// Generates password of length n
|
||||
@ -212,10 +212,10 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
err := store.Open(1, config.StoreConfig)
|
||||
defer store.Close()
|
||||
err := store.Store.Open(1, config.StoreConfig)
|
||||
defer store.Store.Close()
|
||||
|
||||
log.Println("Database", store.GetAdapterName(), store.GetAdapterVersion())
|
||||
log.Println("Database", store.Store.GetAdapterName(), store.Store.GetAdapterVersion())
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "Database not initialized") {
|
||||
@ -224,8 +224,8 @@ func main() {
|
||||
}
|
||||
log.Println("Database not found. Creating.")
|
||||
} else if strings.Contains(err.Error(), "Invalid database version") {
|
||||
msg := "Wrong DB version: expected " + strconv.Itoa(store.GetAdapterVersion()) + ", got " +
|
||||
strconv.Itoa(store.GetDbVersion()) + "."
|
||||
msg := "Wrong DB version: expected " + strconv.Itoa(store.Store.GetAdapterVersion()) + ", got " +
|
||||
strconv.Itoa(store.Store.GetDbVersion()) + "."
|
||||
if *reset {
|
||||
log.Println(msg, "Dropping and recreating the database.")
|
||||
} else if *upgrade {
|
||||
@ -245,13 +245,13 @@ func main() {
|
||||
|
||||
if *upgrade {
|
||||
// Upgrade DB from one version to another.
|
||||
err = store.UpgradeDb(config.StoreConfig)
|
||||
err = store.Store.UpgradeDb(config.StoreConfig)
|
||||
if err == nil {
|
||||
log.Println("Database successfully upgraded.")
|
||||
}
|
||||
} else {
|
||||
// Reset or create DB
|
||||
err = store.InitDb(config.StoreConfig, true)
|
||||
err = store.Store.InitDb(config.StoreConfig, true)
|
||||
if err == nil {
|
||||
var action string
|
||||
if *reset {
|
||||
|
Reference in New Issue
Block a user