From 89bdc1e4963a438112205b58aa500ffc6d67d7e0 Mon Sep 17 00:00:00 2001 From: fumiama Date: Sat, 15 Jan 2022 15:18:25 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=20fix=20gif=20panic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data | 2 +- plugin_gif/context.go | 3 +++ plugin_gif/run.go | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/data b/data index cf3c143a..522acbf5 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit cf3c143aa977994e543ae0893678a5f0628da02b +Subproject commit 522acbf5e32d7f3ba3e72a3b23c442f075a287ff diff --git a/plugin_gif/context.go b/plugin_gif/context.go index 52b91e56..ed84d87d 100644 --- a/plugin_gif/context.go +++ b/plugin_gif/context.go @@ -34,6 +34,9 @@ func dlblock(name string) string { } func dlrange(prefix string, end int) *[]chan *string { + if file.IsNotExist(datapath + `materials/` + prefix) { + _ = os.MkdirAll(datapath+`materials/`+prefix, 0755) + } c := make([]chan *string, end) for i := range c { c[i] = make(chan *string) diff --git a/plugin_gif/run.go b/plugin_gif/run.go index 27b8dac1..fde06000 100644 --- a/plugin_gif/run.go +++ b/plugin_gif/run.go @@ -21,7 +21,11 @@ var ( ) func init() { // 插件主体 - os.RemoveAll(datapath) // 清除缓存图片 + _ = os.RemoveAll(datapath) // 清除缓存图片 + err := os.MkdirAll(datapath, 0755) + if err != nil { + panic(err) + } rand.Seed(time.Now().UnixNano()) // 设置种子 control.Register("gif", &control.Options{ DisableOnDefault: false,