diff --git a/build.sh b/build.sh index 368d2d2cfb05..ce75c8ac8163 100644 --- a/build.sh +++ b/build.sh @@ -64,19 +64,16 @@ BuildDev() { curl -L -o "${i}.tgz" "${url}" sudo tar xf "${i}.tgz" --strip-components 1 -C /usr/local done - OS_ARCHES=(linux-musl-amd64 linux-musl-arm64) - CGO_ARGS=(x86_64-linux-musl-gcc aarch64-linux-musl-gcc) + OS_ARCHES=(linux-amd64) for i in "${!OS_ARCHES[@]}"; do os_arch=${OS_ARCHES[$i]} - cgo_cc=${CGO_ARGS[$i]} echo building for ${os_arch} export GOOS=${os_arch%%-*} - export GOARCH=${os_arch##*-} - export CC=${cgo_cc} + export GOAMD64=v3 export CGO_ENABLED=1 - go build -o ./dist/$appName-$os_arch -ldflags="$muslflags" -tags=jsoniter . + go build -o ./dist/$appName-$os_arch -ldflags="$ldflags" -tags=jsoniter . done - xgo -targets=windows/amd64,darwin/amd64,darwin/arm64 -out "$appName" -ldflags="$ldflags" -tags=jsoniter . + xgo -targets=windows/amd64 -out "$appName" -ldflags="$ldflags" -tags=jsoniter . mv alist-* dist cd dist cp ./alist-windows-amd64.exe ./alist-windows-amd64-upx.exe diff --git a/drivers/terabox/driver.go b/drivers/terabox/driver.go index c9662fce03ac..651916a0b617 100644 --- a/drivers/terabox/driver.go +++ b/drivers/terabox/driver.go @@ -11,6 +11,7 @@ import ( stdpath "path" "strconv" "strings" + "time" "github.com/alist-org/alist/v3/drivers/base" "github.com/alist-org/alist/v3/pkg/utils" @@ -157,17 +158,22 @@ func (d *Terabox) Put(ctx context.Context, dstDir model.Obj, stream model.FileSt rawPath := stdpath.Join(dstDir.GetPath(), stream.GetName()) path := encodeURIComponent(rawPath) block_list_str := fmt.Sprintf("[%s]", strings.Join(block_list, ",")) - data := fmt.Sprintf("path=%s&size=%d&isdir=0&autoinit=1&block_list=%s", - path, stream.GetSize(), - block_list_str) - params := map[string]string{} + data := map[string]string{ + "path": rawPath, + "autoinit": "1", + "target_path": dstDir.GetPath(), + "block_list": block_list_str, + "local_mtime": string(time.Now().Unix()), + } var precreateResp PrecreateResp - _, err = d.post("/api/precreate", params, data, &precreateResp) + log.Debugln(data) + res, err := d.post_form("/api/precreate", nil, data, &precreateResp) if err != nil { return err } log.Debugf("%+v", precreateResp) if precreateResp.Errno != 0 { + log.Debugln(string(res)) return fmt.Errorf("[terabox] failed to precreate file, errno: %d", precreateResp.Errno) } if precreateResp.ReturnType == 2 { @@ -216,7 +222,9 @@ func (d *Terabox) Put(ctx context.Context, dstDir model.Obj, stream model.FileSt up(float64(i) * 100 / float64(len(precreateResp.BlockList))) } } - _, err = d.create(rawPath, stream.GetSize(), 0, precreateResp.Uploadid, block_list_str) + res, err = d.create(rawPath, stream.GetSize(), 0, precreateResp.Uploadid, block_list_str) + log.Debugln(string(res)) + time.Sleep(time.Duration(len(precreateResp.BlockList)/16+10) * time.Second) return err } diff --git a/drivers/terabox/util.go b/drivers/terabox/util.go index 0a4e78793798..477bdb0973e6 100644 --- a/drivers/terabox/util.go +++ b/drivers/terabox/util.go @@ -105,6 +105,15 @@ func (d *Terabox) post(pathname string, params map[string]string, data interface }, resp) } +func (d *Terabox) post_form(pathname string, params map[string]string, data map[string]string, resp interface{}) ([]byte, error) { + return d.request("https://www.terabox.com"+pathname, http.MethodPost, func(req *resty.Request) { + if params != nil { + req.SetQueryParams(params) + } + req.SetFormData(data) + }, resp) +} + func (d *Terabox) getFiles(dir string) ([]File, error) { page := 1 num := 100 @@ -238,7 +247,7 @@ func (d *Terabox) manage(opera string, filelist interface{}) ([]byte, error) { } func (d *Terabox) create(path string, size int64, isdir int, uploadid, block_list string) ([]byte, error) { - params := map[string]string{} + params := map[string]string{"rtype": "1"} data := fmt.Sprintf("path=%s&size=%d&isdir=%d", encodeURIComponent(path), size, isdir) if uploadid != "" { data += fmt.Sprintf("&uploadid=%s&block_list=%s", uploadid, block_list)