diff --git a/bootstrap/conf.go b/bootstrap/conf.go index 246d3114..1a171474 100644 --- a/bootstrap/conf.go +++ b/bootstrap/conf.go @@ -1,7 +1,6 @@ package bootstrap import ( - "encoding/json" "github.com/Xhofe/alist/conf" "github.com/Xhofe/alist/utils" log "github.com/sirupsen/logrus" @@ -28,7 +27,7 @@ func InitConf() { log.Fatalf("reading config file error:%s", err.Error()) } conf.Conf = new(conf.Config) - err = json.Unmarshal(config, conf.Conf) + err = utils.Json.Unmarshal(config, conf.Conf) if err != nil { log.Fatalf("load config error: %s", err.Error()) } diff --git a/build.sh b/build.sh index 5ff616e9..381aa3fd 100644 --- a/build.sh +++ b/build.sh @@ -26,7 +26,7 @@ if [ "$1" == "docker" ]; then -X 'github.com/Xhofe/alist/conf.GitCommit=$gitCommit' \ -X 'github.com/Xhofe/alist/conf.GitTag=$gitTag' \ " - go build -o ./bin/alist -ldflags="$ldflags" alist.go + go build -o ./bin/alist -ldflags="$ldflags" -tags=jsoniter alist.go exit 0 fi @@ -68,9 +68,9 @@ ldflags="\ " if [ "$1" == "release" ]; then - xgo -out alist -ldflags="$ldflags" . + xgo -out alist -ldflags="$ldflags" -tags=jsoniter . else - xgo -targets=linux/amd64,windows/amd64 -out alist -ldflags="$ldflags" . + xgo -targets=linux/amd64,windows/amd64 -out alist -ldflags="$ldflags" -tags=jsoniter . fi mkdir "build" mv alist-* build diff --git a/drivers/189/189.go b/drivers/189/189.go index c14e9ae5..1e4c98b4 100644 --- a/drivers/189/189.go +++ b/drivers/189/189.go @@ -10,7 +10,6 @@ import ( "crypto/x509" "encoding/base64" "encoding/hex" - "encoding/json" "encoding/pem" "errors" "fmt" @@ -158,7 +157,7 @@ func (driver Cloud189) Login(account *model.Account) error { if err != nil { return err } - err = json.Unmarshal(res.Body(), &loginResp) + err = utils.Json.Unmarshal(res.Body(), &loginResp) if err != nil { log.Error(err.Error()) return err diff --git a/drivers/189/driver.go b/drivers/189/driver.go index eea3cdac..75ca8e59 100644 --- a/drivers/189/driver.go +++ b/drivers/189/driver.go @@ -5,7 +5,6 @@ import ( "crypto/md5" "encoding/base64" "encoding/hex" - "encoding/json" "fmt" "github.com/Xhofe/alist/conf" "github.com/Xhofe/alist/drivers/base" @@ -233,7 +232,6 @@ func (driver Cloud189) Move(src string, dst string, account *model.Account) erro if err != nil { return err } - dstDirFile, err := driver.File(dstDir, account) if err != nil { return err @@ -249,7 +247,7 @@ func (driver Cloud189) Move(src string, dst string, account *model.Account) erro "isFolder": isFolder, }, } - taskInfosBytes, err := json.Marshal(taskInfos) + taskInfosBytes, err := utils.Json.Marshal(taskInfos) if err != nil { return err } @@ -305,7 +303,7 @@ func (driver Cloud189) Copy(src string, dst string, account *model.Account) erro "isFolder": isFolder, }, } - taskInfosBytes, err := json.Marshal(taskInfos) + taskInfosBytes, err := utils.Json.Marshal(taskInfos) if err != nil { return err } @@ -335,7 +333,7 @@ func (driver Cloud189) Delete(path string, account *model.Account) error { "isFolder": isFolder, }, } - taskInfosBytes, err := json.Marshal(taskInfos) + taskInfosBytes, err := utils.Json.Marshal(taskInfos) if err != nil { return err } @@ -424,9 +422,6 @@ func (driver Cloud189) Upload(file *model.FileStream, account *model.Account) er "sliceMd5": utils.GetMD5Encode(strings.Join(md5s, "\n")), "lazyCheck": "1", }, account) - if err == nil { - _ = base.DeleteCache(file.ParentPath, account) - } return err } diff --git a/drivers/shandian/driver.go b/drivers/shandian/driver.go index d44b8f3c..5fb0aed9 100644 --- a/drivers/shandian/driver.go +++ b/drivers/shandian/driver.go @@ -235,7 +235,11 @@ func (driver Shandian) Upload(file *model.FileStream, account *model.Account) er "id": parentId, "name": file.GetFileName(), } - _, err = driver.Post("https://shandianpan.com/api/pan/upload", data, &resp, account) + res, err := driver.Post("https://shandianpan.com/api/pan/upload", data, nil, account) + if err != nil { + return err + } + err = utils.Json.Unmarshal(res, &resp) if err != nil { return err } diff --git a/utils/json.go b/utils/json.go new file mode 100644 index 00000000..159da605 --- /dev/null +++ b/utils/json.go @@ -0,0 +1,5 @@ +package utils + +import jsoniter "github.com/json-iterator/go" + +var Json = jsoniter.ConfigCompatibleWithStandardLibrary