Use default blobstore in Grumble.

This commit is contained in:
Mikkel Krautz 2011-05-13 17:07:55 +02:00
parent 4ac0c4c244
commit 690e5bc750
5 changed files with 20 additions and 17 deletions

View file

@ -13,6 +13,7 @@ import (
"goprotobuf.googlecode.com/hg/proto"
"mumbleproto"
"cryptstate"
"grumble/blobstore"
"io"
"packetdatastream"
)
@ -543,7 +544,7 @@ func (client *Client) sendChannelTree(channel *Channel) {
if client.Version >= 0x10202 {
chanstate.DescriptionHash = channel.DescriptionBlobHashBytes()
} else {
buf, err := globalBlobstore.Get(channel.DescriptionBlob)
buf, err := blobstore.Get(channel.DescriptionBlob)
if err != nil {
panic("Blobstore error.")
}

View file

@ -27,7 +27,6 @@ var sqlitedb *string = flag.String("murmurdb", "", "Path to murmur.sqlite to imp
var cleanup *bool = flag.Bool("clean", false, "Clean up existing data dir content before importing Murmur data")
var gencert *bool = flag.Bool("gencert", false, "Generate a self-signed certificate for use with Grumble")
var globalBlobstore *blobstore.BlobStore
var servers map[int64]*Server
func Usage() {
@ -103,7 +102,7 @@ func main() {
}
log.Printf("Using blob directory: %s", *blobdir)
globalBlobstore, err = blobstore.NewBlobStore(*blobdir, true)
err = blobstore.Open(*blobdir, true)
if err != nil {
log.Fatalf("Unable to initialize blobstore: %v", err.String())
}

View file

@ -10,6 +10,7 @@ import (
"net"
"cryptstate"
"fmt"
"grumble/blobstore"
)
// These are the different kinds of messages
@ -234,7 +235,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) {
key := ""
if len(description) > 0 {
key, err = globalBlobstore.Put([]byte(description))
key, err = blobstore.Put([]byte(description))
if err != nil {
server.Panicf("Blobstore error: %v", err.String())
}
@ -413,7 +414,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) {
// Description change
if chanstate.Description != nil {
key, err := globalBlobstore.Put([]byte(*chanstate.Description))
key, err := blobstore.Put([]byte(*chanstate.Description))
if err != nil {
server.Panicf("Blobstore error: %v", err.String())
}
@ -635,7 +636,7 @@ func (server *Server) handleUserStateMessage(client *Client, msg *Message) {
broadcast := false
if userstate.Texture != nil && target.user != nil {
key, err := globalBlobstore.Put(userstate.Texture)
key, err := blobstore.Put(userstate.Texture)
if err != nil {
server.Panicf("Blobstore error: %v", err.String())
}
@ -675,7 +676,7 @@ func (server *Server) handleUserStateMessage(client *Client, msg *Message) {
}
if userstate.Comment != nil && target.user != nil {
key, err := globalBlobstore.Put([]byte(*userstate.Comment))
key, err := blobstore.Put([]byte(*userstate.Comment))
if err != nil {
server.Panicf("Blobstore error: %v", err.String())
}
@ -1147,7 +1148,7 @@ func (server *Server) handleRequestBlob(client *Client, msg *Message) {
continue
}
if target.user.HasTexture() {
buf, err := globalBlobstore.Get(target.user.TextureBlob)
buf, err := blobstore.Get(target.user.TextureBlob)
if err != nil {
server.Panicf("Blobstore error: %v", err.String())
}
@ -1171,7 +1172,7 @@ func (server *Server) handleRequestBlob(client *Client, msg *Message) {
continue
}
if target.user.HasComment() {
buf, err := globalBlobstore.Get(target.user.CommentBlob)
buf, err := blobstore.Get(target.user.CommentBlob)
if err != nil {
server.Panicf("Blobstore error: %v", err.String())
}
@ -1195,7 +1196,7 @@ func (server *Server) handleRequestBlob(client *Client, msg *Message) {
if channel, ok := server.Channels[int(cid)]; ok {
if channel.HasDescription() {
chanstate.Reset()
buf, err := globalBlobstore.Get(channel.DescriptionBlob)
buf, err := blobstore.Get(channel.DescriptionBlob)
if err != nil {
server.Panicf("Blobstore error: %v", err.String())
}

View file

@ -10,6 +10,7 @@ package main
// SQLite datbase into a format that Grumble can understand.
import (
"grumble/blobstore"
"os"
"sqlite"
"strconv"
@ -87,7 +88,7 @@ func populateChannelInfoFromDatabase(server *Server, c *Channel, db *sqlite.Conn
return err
}
key, err := globalBlobstore.Put([]byte(description))
key, err := blobstore.Put([]byte(description))
if err != nil {
return err
}
@ -361,7 +362,7 @@ func populateUsers(server *Server, db *sqlite.Conn) (err os.Error) {
user.Password = "sha1$$" + SHA1Password
key, err := globalBlobstore.Put(Texture)
key, err := blobstore.Put(Texture)
if err != nil {
return err
}
@ -405,7 +406,7 @@ func populateUsers(server *Server, db *sqlite.Conn) (err os.Error) {
case UserInfoEmail:
user.Email = Value
case UserInfoComment:
key, err := globalBlobstore.Put([]byte(Value))
key, err := blobstore.Put([]byte(Value))
if err != nil {
return err
}

View file

@ -21,6 +21,7 @@ import (
"cryptstate"
"fmt"
"gob"
"grumble/blobstore"
"grumble/serverconf"
"hash"
"io"
@ -602,7 +603,7 @@ func (server *Server) finishAuthenticate(client *Client) {
if client.Version >= 0x10203 {
userstate.TextureHash = client.user.TextureBlobHashBytes()
} else {
buf, err := globalBlobstore.Get(client.user.TextureBlob)
buf, err := blobstore.Get(client.user.TextureBlob)
if err != nil {
server.Panicf("Blobstore error: %v", err.String())
}
@ -615,7 +616,7 @@ func (server *Server) finishAuthenticate(client *Client) {
if client.Version >= 0x10203 {
userstate.CommentHash = client.user.CommentBlobHashBytes()
} else {
buf, err := globalBlobstore.Get(client.user.CommentBlob)
buf, err := blobstore.Get(client.user.CommentBlob)
if err != nil {
server.Panicf("Blobstore error: %v", err.String())
}
@ -750,7 +751,7 @@ func (server *Server) sendUserList(client *Client) {
if client.Version >= 0x10203 {
userstate.TextureHash = connectedClient.user.TextureBlobHashBytes()
} else {
buf, err := globalBlobstore.Get(connectedClient.user.TextureBlob)
buf, err := blobstore.Get(connectedClient.user.TextureBlob)
if err != nil {
server.Panicf("Blobstore error: %v", err.String())
}
@ -763,7 +764,7 @@ func (server *Server) sendUserList(client *Client) {
if client.Version >= 0x10203 {
userstate.CommentHash = connectedClient.user.CommentBlobHashBytes()
} else {
buf, err := globalBlobstore.Get(connectedClient.user.CommentBlob)
buf, err := blobstore.Get(connectedClient.user.CommentBlob)
if err != nil {
server.Panicf("Blobstore error: %v", err.String())
}