From 66aade24e48fa77a6f68b238da0ccfc86d602d84 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Sun, 31 Mar 2024 21:41:17 +0500 Subject: [PATCH] rm import rclone and add test action --- .github/workflows/s3tests.yml | 34 ++++++++++++++++++++++++++++++-- weed/operation/upload_content.go | 6 +++--- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/.github/workflows/s3tests.yml b/.github/workflows/s3tests.yml index dfd3d4acf..70ed73614 100644 --- a/.github/workflows/s3tests.yml +++ b/.github/workflows/s3tests.yml @@ -34,14 +34,18 @@ jobs: go-version-file: 'go.mod' id: go + - name: Build weed + shell: bash + run: | + cd /__w/seaweedfs/seaweedfs/weed + go install -buildvcs=false + - name: Run Ceph S3 tests timeout-minutes: 15 env: S3TEST_CONF: /__w/seaweedfs/seaweedfs/docker/compose/s3tests.conf shell: bash run: | - cd /__w/seaweedfs/seaweedfs/weed - go install -buildvcs=false set -x nohup weed -v 0 server -filer -s3 -ip.bind 0.0.0.0 \ -master.raftHashicorp -master.electionTimeout 1s -master.volumeSizeLimitMB=1024 \ @@ -187,3 +191,29 @@ jobs: s3tests_boto3/functional/test_s3.py::test_ranged_request_return_trailing_bytes_response_code \ s3tests_boto3/functional/test_s3.py::test_copy_object_ifmatch_good \ s3tests_boto3/functional/test_s3.py::test_copy_object_ifnonematch_failed + + - uses: actions/checkout@v4 + with: + repository: "rclone/rclone" + + - name: Run Rclone S3 tests + timeout-minutes: 15 + env: + RCLONE_CONFIG_SWFS_TYPE: s3 + RCLONE_CONFIG_SWFS_PROVIDER: Other + RCLONE_CONFIG_SWFS_ACCESS_KEY_ID: some_access_key1 + RCLONE_CONFIG_SWFS_SECRET_ACCESS_KEY: some_secret_key1 + RCLONE_CONFIG_SWFS_ENDPOINT: http://localhost:8000 + RCLONE_CONFIG_SWFS_UPLOAD_CUTOFF: 50Mi + RCLONE_CONFIG_SWFS_CHUNK_SIZE: 50Mi + RCLONE_CONFIG_SWFS_FORCE_PATH_STYLE: true + shell: bash + run: | + set -x + nohup weed -v 0 server -filer -s3 -ip.bind 0.0.0.0 \ + -master.raftHashicorp -master.electionTimeout 1s -master.volumeSizeLimitMB=1024 \ + -volume.max=100 -volume.preStopSeconds=1 -s3.port=8000 -metricsPort=9324 \ + -s3.allowEmptyFolder=false -s3.allowDeleteBucketNotEmpty=true -s3.config=../docker/compose/s3.json & + sleep 10 + cd /__w/seaweedfs/seaweedfs/rclone/rclone/backend/s3 + go test -v -remote swfs: diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go index f644265ca..aa40eff14 100644 --- a/weed/operation/upload_content.go +++ b/weed/operation/upload_content.go @@ -5,7 +5,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/rclone/rclone/lib/encoder" "io" "mime" "mime/multipart" @@ -67,7 +66,8 @@ type HTTPClient interface { } var ( - HttpClient HTTPClient + HttpClient HTTPClient + fileNameEscaper = strings.NewReplacer(`\`, `\\`, `"`, `\"`) ) func init() { @@ -278,7 +278,7 @@ func upload_content(fillBufferFunction func(w io.Writer) error, originalDataSize defer PutBuffer(buf) body_writer := multipart.NewWriter(buf) h := make(textproto.MIMEHeader) - filename := encoder.Standard.Encode(option.Filename) + filename := fileNameEscaper.Replace(strings.Trim(option.Filename, "\n\r\t\v")) h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="file"; filename="%s"`, filename)) h.Set("Idempotency-Key", option.UploadUrl) if option.MimeType == "" {