Little profile refactoring and favorite server adding fix.
Done some refactoring on profiles handling. Too small, but deserve these two lines in commit. Fixed favorite server addition from scratch.
This commit is contained in:
parent
a6d53a3fd9
commit
070aa50762
2
cache/cache_profiles.go
vendored
2
cache/cache_profiles.go
vendored
@ -47,8 +47,8 @@ func (c *Cache) deleteProfile(data map[string]string) {
|
||||
_, ok1 := c.Profiles[data["profile_name"]]
|
||||
c.ProfilesMutex.Unlock()
|
||||
if !ok1 {
|
||||
fmt.Println("Profile deleted")
|
||||
Database.Db.MustExec(Database.Db.Rebind("DELETE FROM urt_profiles WHERE name=?"), data["profile_name"])
|
||||
fmt.Println("Profile deleted")
|
||||
} else {
|
||||
fmt.Println("Something goes wrong! Profile is still here!")
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ type Pooler struct {
|
||||
func (p *Pooler) Initialize() {
|
||||
fmt.Println("Initializing requester goroutine pooler...")
|
||||
// ToDo: figure out how to make this work nice.
|
||||
p.maxrequests = 200
|
||||
p.maxrequests = 150
|
||||
_ = runtime.GOMAXPROCS(runtime.NumCPU() * 4)
|
||||
p.pp = "\377\377\377\377"
|
||||
fmt.Println("Pooler initialized")
|
||||
|
@ -91,6 +91,7 @@ func (t *Timer) Initialize() {
|
||||
fmt.Println("Initializing timer...")
|
||||
|
||||
t.initializeStorage()
|
||||
Eventer.AddEventHandler("taskDone", t.SetTaskNotInProgress)
|
||||
|
||||
ticker := time.NewTicker(time.Second * 1)
|
||||
go func() {
|
||||
@ -98,8 +99,6 @@ func (t *Timer) Initialize() {
|
||||
go t.executeTasks()
|
||||
}
|
||||
}()
|
||||
|
||||
Eventer.AddEventHandler("taskDone", t.SetTaskNotInProgress)
|
||||
}
|
||||
|
||||
func (t *Timer) initializeStorage() {
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"strings"
|
||||
|
||||
// Local
|
||||
"github.com/pztrn/urtrator/cachemodels"
|
||||
"github.com/pztrn/urtrator/common"
|
||||
"github.com/pztrn/urtrator/datamodels"
|
||||
|
||||
@ -247,8 +248,17 @@ func (f *FavoriteDialog) saveFavorite() error {
|
||||
}
|
||||
|
||||
fmt.Println("Saving favorite server...")
|
||||
fmt.Println(fmt.Sprintf("%+v", f.server))
|
||||
|
||||
key := strings.Split(f.server_address.GetText(), ":")[0] + ":" + port
|
||||
|
||||
// Check if server already in cache. This would replace data about it.
|
||||
_, ok := ctx.Cache.Servers[key]
|
||||
if !ok {
|
||||
ctx.Cache.Servers[key] = &cachemodels.Server{}
|
||||
ctx.Cache.Servers[key].Server = &datamodels.Server{}
|
||||
}
|
||||
|
||||
ctx.Cache.Servers[key].Server.Ip = f.server.Ip
|
||||
ctx.Cache.Servers[key].Server.Port = f.server.Port
|
||||
ctx.Cache.Servers[key].Server.Name = f.server.Name
|
||||
|
Reference in New Issue
Block a user