chore: update deps

This commit is contained in:
源文雨
2024-11-07 00:12:51 +09:00
parent f5e1c197dd
commit 83ca8c344b
57 changed files with 274 additions and 300 deletions

View File

@@ -24,11 +24,11 @@ import (
// Pools 图片缓冲池
type imgpool struct {
db *sql.Sqlite
db sql.Sqlite
dbmu sync.RWMutex
path string
max int
pool map[string][]*message.MessageSegment
pool map[string][]*message.Segment
poolmu sync.Mutex
}
@@ -44,10 +44,9 @@ func (p *imgpool) List() (l []string) {
}
var pool = &imgpool{
db: &sql.Sqlite{},
path: pixiv.CacheDir,
max: 10,
pool: make(map[string][]*message.MessageSegment),
pool: make(map[string][]*message.Segment),
}
func init() { // 插件主体
@@ -63,7 +62,7 @@ func init() { // 插件主体
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
// 如果数据库不存在则下载
pool.db.DBPath = engine.DataFolder() + "SetuTime.db"
pool.db = sql.New(engine.DataFolder() + "SetuTime.db")
_, _ = engine.GetLazyData("SetuTime.db", false)
err := pool.db.Open(time.Hour)
if err != nil {
@@ -157,7 +156,7 @@ func (p *imgpool) push(ctx *zero.Ctx, imgtype string, illust *pixiv.Illust) {
if len(illust.ImageUrls) == 0 {
return
}
var msg message.MessageSegment
var msg message.Segment
f := fileutil.BOTPATH + "/" + illust.Path(0)
if fileutil.IsNotExist(f) {
// 下载图片
@@ -172,7 +171,7 @@ func (p *imgpool) push(ctx *zero.Ctx, imgtype string, illust *pixiv.Illust) {
p.poolmu.Unlock()
}
func (p *imgpool) pop(imgtype string) (msg *message.MessageSegment) {
func (p *imgpool) pop(imgtype string) (msg *message.Segment) {
p.poolmu.Lock()
defer p.poolmu.Unlock()
if p.size(imgtype) == 0 {
@@ -229,5 +228,5 @@ func (p *imgpool) add(ctx *zero.Ctx, imgtype string, id int64) error {
func (p *imgpool) remove(imgtype string, id int64) error {
p.dbmu.Lock()
defer p.dbmu.Unlock()
return p.db.Del(imgtype, fmt.Sprintf("WHERE pid=%d", id))
return p.db.Del(imgtype, "WHERE pid = ?", id)
}