mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 22:42:15 +08:00
change plugin folder
This commit is contained in:
parent
c1115dfcc7
commit
56a06d495e
@ -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() // 开始计时
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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()))
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user