mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 19:43:49 +08:00
fix codec path
This commit is contained in:
parent
de4de5052d
commit
7a9a021c54
@ -14,7 +14,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
codecDir string
|
|
||||||
encoderPath string
|
encoderPath string
|
||||||
cachePath string
|
cachePath string
|
||||||
)
|
)
|
||||||
@ -37,23 +36,16 @@ func downloadCodec(url string, path string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Init(cachePath, codecPath string) error {
|
func Init(cachePath, codecPath string) error {
|
||||||
appPath, err := os.Executable()
|
if !fileExist(codecPath) {
|
||||||
appPath = path.Dir(appPath)
|
_ = os.MkdirAll(codecPath, os.ModePerm)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
cachePath = path.Join(appPath, cachePath)
|
|
||||||
codecDir = path.Join(appPath, codecPath)
|
|
||||||
if !fileExist(codecDir) {
|
|
||||||
_ = os.MkdirAll(codecDir, os.ModePerm)
|
|
||||||
}
|
}
|
||||||
if !fileExist(cachePath) {
|
if !fileExist(cachePath) {
|
||||||
_ = os.MkdirAll(cachePath, os.ModePerm)
|
_ = os.MkdirAll(cachePath, os.ModePerm)
|
||||||
}
|
}
|
||||||
encoderFile := runtime.GOOS + "-" + runtime.GOARCH + "-encoder"
|
encoderFile := runtime.GOOS + "-" + runtime.GOARCH + "-encoder"
|
||||||
encoderPath = path.Join(codecDir, encoderFile)
|
encoderPath = path.Join(codecPath, encoderFile)
|
||||||
if !fileExist(encoderPath) {
|
if !fileExist(encoderPath) {
|
||||||
if err = downloadCodec("https://cdn.jsdelivr.net/gh/wdvxdr1123/tosilk/codec/"+encoderFile, encoderPath); err != nil {
|
if err := downloadCodec("https://cdn.jsdelivr.net/gh/wdvxdr1123/tosilk/codec/"+encoderFile, encoderPath); err != nil {
|
||||||
return errors.New("下载依赖失败")
|
return errors.New("下载依赖失败")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user