handle no db yet in message retrieve
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@ -90,6 +90,10 @@ func StoreMessage(peer *Peer, usermessage *meowlib.UserMessage, filenames []stri
|
||||
// Get new messages from a peer
|
||||
func GetNewMessages(peer *Peer, lastDbId int, password string) ([]*InternalUserMessage, error) {
|
||||
var messages []*InternalUserMessage
|
||||
// handle no db yet
|
||||
if len(peer.DbIds) == 0 {
|
||||
return messages, nil
|
||||
}
|
||||
fileidx := len(peer.DbIds) - 1
|
||||
// There fileidx should provide the db that we need (unless wantMore overlaps the next DB)
|
||||
db, _ := sql.Open("sqlite3", filepath.Join(GetConfig().StoragePath, peer.DbIds[fileidx]+GetConfig().DbSuffix)) // Open the created SQLite File
|
||||
@ -139,6 +143,10 @@ func GetNewMessages(peer *Peer, lastDbId int, password string) ([]*InternalUserM
|
||||
// Get old messages from a peer
|
||||
func GetMessagesHistory(peer *Peer, inAppMsgCount int, lastDbId int, wantMore int, password string) ([]InternalUserMessage, error) {
|
||||
var messages []InternalUserMessage
|
||||
// handle no db yet
|
||||
if len(peer.DbIds) == 0 {
|
||||
return messages, nil
|
||||
}
|
||||
fileidx := len(peer.DbIds) - 1
|
||||
// initialize count with last db message count
|
||||
countStack, err := getMessageCount(peer.DbIds[fileidx])
|
||||
|
Reference in New Issue
Block a user