diff --git a/plugin_nativesetu/data.go b/plugin_nativesetu/data.go index b12a795d..76376dd7 100644 --- a/plugin_nativesetu/data.go +++ b/plugin_nativesetu/data.go @@ -25,7 +25,7 @@ type setuclass struct { Path string `db:"path"` // Path 图片路径 } -var ns *nsetu +var ns = &nsetu{db: &sql.Sqlite{DBPath: dbfile}} func init() { go func() { @@ -41,7 +41,6 @@ func init() { logrus.Println("[nsetu] set setu dir to", setupath) } } - ns = &nsetu{db: &sql.Sqlite{DBPath: dbfile}} }() } diff --git a/plugin_setutime/setu_geter.go b/plugin_setutime/setu_geter.go index 3b59b0b3..807429ce 100644 --- a/plugin_setutime/setu_geter.go +++ b/plugin_setutime/setu_geter.go @@ -44,19 +44,18 @@ func (p *imgpool) List() (l []string) { 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() { // 插件主体 _ = os.MkdirAll("data/SetuTime", 0755) go func() { 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) err := pool.db.Open()