🐛 fix nil ptr

This commit is contained in:
fumiama 2022-01-30 23:05:13 +08:00
parent a2854069ac
commit e1dbfe8f6a
2 changed files with 7 additions and 9 deletions

View File

@ -25,7 +25,7 @@ type setuclass struct {
Path string `db:"path"` // Path 图片路径 Path string `db:"path"` // Path 图片路径
} }
var ns *nsetu var ns = &nsetu{db: &sql.Sqlite{DBPath: dbfile}}
func init() { func init() {
go func() { go func() {
@ -41,7 +41,6 @@ func init() {
logrus.Println("[nsetu] set setu dir to", setupath) logrus.Println("[nsetu] set setu dir to", setupath)
} }
} }
ns = &nsetu{db: &sql.Sqlite{DBPath: dbfile}}
}() }()
} }

View File

@ -44,19 +44,18 @@ func (p *imgpool) List() (l []string) {
return l return l
} }
var pool *imgpool var pool = &imgpool{
db: &sql.Sqlite{DBPath: "data/SetuTime/SetuTime.db"},
path: pixiv.CacheDir,
max: 10,
pool: map[string][]*pixiv.Illust{},
}
func init() { // 插件主体 func init() { // 插件主体
_ = os.MkdirAll("data/SetuTime", 0755) _ = os.MkdirAll("data/SetuTime", 0755)
go func() { go func() {
process.SleepAbout1sTo2s() process.SleepAbout1sTo2s()
pool = &imgpool{
db: &sql.Sqlite{DBPath: "data/SetuTime/SetuTime.db"},
path: pixiv.CacheDir,
max: 10,
pool: map[string][]*pixiv.Illust{},
}
// 如果数据库不存在则下载 // 如果数据库不存在则下载
_, _ = fileutil.GetLazyData(pool.db.DBPath, false, false) _, _ = fileutil.GetLazyData(pool.db.DBPath, false, false)
err := pool.db.Open() err := pool.db.Open()