change plugin folder

This commit is contained in:
tickstep 2022-04-20 21:56:47 +08:00
parent c1115dfcc7
commit 56a06d495e
5 changed files with 14 additions and 2 deletions

View File

@ -298,7 +298,7 @@ func RunUpload(localPaths []string, savePath string, opt *UploadOptions) {
folderCreateMutex = &sync.Mutex{}
pluginManger = plugins.NewPluginManager(config.GetConfigDir())
pluginManger = plugins.NewPluginManager(config.GetPluginDir())
)
executor.SetParallel(opt.AllParallel)
statistic.StartTimer() // 开始计时

View File

@ -308,6 +308,10 @@ func GetConfigDir() string {
return configDir
}
func GetPluginDir() string {
return strings.TrimSuffix(GetConfigDir(), "/") + "/plugin"
}
func (c *PanConfig) ActiveUser() *PanUser {
if c.activeUser == nil {
if c.UserList == nil {

View File

@ -53,7 +53,7 @@ func (js *JsPlugin) Start() error {
func (js *JsPlugin) LoadScript(script string) error {
_, err := js.vm.RunString(script)
if err != nil {
logger.Verboseln("JS代码有问题")
logger.Verboseln("JS代码有问题{}", err)
return err
}
return nil

View File

@ -58,6 +58,9 @@ func (p *PluginManager) GetPlugin() (Plugin, error) {
if files, e := ioutil.ReadDir(jsPluginPath); e == nil {
for _, f := range files {
if !f.IsDir() {
if strings.HasPrefix(strings.ToLower(f.Name()), ".") || strings.HasPrefix(strings.ToLower(f.Name()), "~") {
continue
}
if strings.HasSuffix(strings.ToLower(f.Name()), ".js") {
// this is a js file
bytes, re := ioutil.ReadFile(path.Clean(jsPluginPath + string(os.PathSeparator) + f.Name()))

View File

@ -2,6 +2,7 @@ package plugins
import (
"fmt"
jsoniter "github.com/json-iterator/go"
"testing"
)
@ -28,6 +29,10 @@ func TestPlugin(t *testing.T) {
DriveId: "19519221",
DriveFilePath: "aliyunpan/Downloads/11001d48564f43b3bc5662874f04bb11/token.bat",
}
b, _ := jsoniter.Marshal(ctx)
fmt.Println(string(b))
b, _ = jsoniter.Marshal(params)
fmt.Println(string(b))
r, e := plugin.UploadFilePrepareCallback(ctx, params)
if e != nil {
fmt.Println(e)