This commit is contained in:
nikk gitanes
2023-02-18 23:23:11 +03:00
parent ec4deb8afe
commit 7822157ff2
22 changed files with 62 additions and 69 deletions

View File

@@ -53,9 +53,7 @@ func (v *BTSets) String() string {
return string(buf)
}
var (
BTsets *BTSets
)
var BTsets *BTSets
func SetBTSets(sets *BTSets) {
if ReadOnly {

View File

@@ -16,7 +16,7 @@ type TDB struct {
}
func NewTDB() *TDB {
db, err := bolt.Open(filepath.Join(Path, "config.db"), 0666, &bolt.Options{Timeout: 5 * time.Second})
db, err := bolt.Open(filepath.Join(Path, "config.db"), 0o666, &bolt.Options{Timeout: 5 * time.Second})
if err != nil {
log.TLogln(err)
return nil
@@ -60,7 +60,6 @@ func (v *TDB) Get(xpath, name string) []byte {
ret = buckt.Get([]byte(name))
return nil
})
if err != nil {
log.TLogln("Error get sets", xpath+"/"+name, ", error:", err)
}
@@ -95,12 +94,10 @@ func (v *TDB) Set(xpath, name string, value []byte) {
return buckt.Put([]byte(name), value)
})
if err != nil {
log.TLogln("Error put sets", xpath+"/"+name, ", error:", err)
log.TLogln("value:", value)
}
}
func (v *TDB) List(xpath string) []string {
@@ -134,7 +131,6 @@ func (v *TDB) List(xpath string) []string {
return nil
})
if err != nil {
log.TLogln("Error list sets", xpath, ", error:", err)
}
@@ -169,9 +165,7 @@ func (v *TDB) Rem(xpath, name string) {
return buckt.Delete([]byte(name))
})
if err != nil {
log.TLogln("Error rem sets", xpath+"/"+name, ", error:", err)
}
}

View File

@@ -11,9 +11,7 @@ import (
"server/web/api/utils"
)
var (
dbTorrentsName = []byte("Torrents")
)
var dbTorrentsName = []byte("Torrents")
type torrentOldDB struct {
Name string
@@ -29,7 +27,7 @@ func Migrate() {
return
}
db, err := bolt.Open(filepath.Join(Path, "torrserver.db"), 0666, nil)
db, err := bolt.Open(filepath.Join(Path, "torrserver.db"), 0o666, nil)
if err != nil {
return
}

View File

@@ -69,7 +69,7 @@ func ListViewed(hash string) []*Viewed {
err = json.Unmarshal(buf, &indeces)
if err == nil {
var ret []*Viewed
for i, _ := range indeces {
for i := range indeces {
ret = append(ret, &Viewed{hash, i})
}
return ret
@@ -85,7 +85,7 @@ func ListViewed(hash string) []*Viewed {
var indeces map[int]struct{}
err = json.Unmarshal(buf, &indeces)
if err == nil {
for i, _ := range indeces {
for i := range indeces {
ret = append(ret, &Viewed{key, i})
}
}