From 7c0bcb1c13f910dd1af6dd9f3588d7615dc1fdee Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Thu, 9 Nov 2023 15:53:55 +0530 Subject: [PATCH 1/2] update gosdk --- go.mod | 4 +++- go.sum | 7 +++++-- go.work.sum | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index fabe02ac4..1876e81f0 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( cloud.google.com/go/storage v1.27.0 github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.8.18-0.20230901213317-53d640a9b7f9 + github.com/0chain/gosdk v1.8.18-0.20231109073018-b1b3c2a0899d github.com/Azure/azure-pipeline-go v0.2.2 github.com/Azure/azure-storage-blob-go v0.10.0 github.com/Shopify/sarama v1.28.0 @@ -208,6 +208,7 @@ require ( github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021 // indirect github.com/prometheus/common v0.39.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect + github.com/remeh/sizedwaitgroup v1.0.0 // indirect github.com/rivo/uniseg v0.4.3 // indirect github.com/rjeczalik/notify v0.9.2 // indirect github.com/rs/xid v1.3.0 // indirect @@ -250,6 +251,7 @@ require ( gopkg.in/h2non/filetype.v1 v1.0.5 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/square/go-jose.v2 v2.3.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 0ea79d120..54e09fc04 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E= github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM= github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc= -github.com/0chain/gosdk v1.8.18-0.20230901213317-53d640a9b7f9 h1:GHTdYTmhNY9genBkNWLXdn3Z1yCtcbSNkcIFaKrqBRU= -github.com/0chain/gosdk v1.8.18-0.20230901213317-53d640a9b7f9/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= +github.com/0chain/gosdk v1.8.18-0.20231109073018-b1b3c2a0899d h1:gRV8ogRwXJXQl5jJflLeZGgBDWtr+EPPd4KrKwPH15w= +github.com/0chain/gosdk v1.8.18-0.20231109073018-b1b3c2a0899d/go.mod h1:d3YLgnSKvEtZ6I9taIQotb6xcMvUKvd01JnkXS+O1jk= github.com/Azure/azure-amqp-common-go/v2 v2.1.0/go.mod h1:R8rea+gJRuJR6QxTir/XuEd+YuKoUiazDC/N96FiDEU= github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= github.com/Azure/azure-pipeline-go v0.2.2 h1:6oiIS9yaG6XCCzhgAgKFfIWyo4LLCiDhZot6ltoThhY= @@ -1431,6 +1431,8 @@ github.com/quasilyte/go-ruleguard v0.1.2-0.20200318202121-b00d7a75d3d8/go.mod h1 github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/remeh/sizedwaitgroup v1.0.0 h1:VNGGFwNo/R5+MJBf6yrsr110p0m4/OX4S3DCy7Kyl5E= +github.com/remeh/sizedwaitgroup v1.0.0/go.mod h1:3j2R4OIe/SeS6YDhICBy22RWjJC5eNCJ1V+9+NVNYlo= github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= @@ -2330,6 +2332,7 @@ gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= diff --git a/go.work.sum b/go.work.sum index d5ba6fb62..0f6d9de9e 100644 --- a/go.work.sum +++ b/go.work.sum @@ -128,6 +128,8 @@ cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT github.com/0chain/gorocksdb v0.0.0-20220406081817-640f6b0a3abb/go.mod h1:3i9d+2Osik7apjXERxpAlKxE7SilJKkHoW9Ihdjdfxs= github.com/0chain/gosdk v1.8.5 h1:vZGart1W3pijEF3mhGk3d4CBsrRo4iqLxORY7rRkIP4= github.com/0chain/gosdk v1.8.5/go.mod h1:JeaXA7gbncHoYbKixUnM58+7S2E9z7IKYY+fV0IQJ/o= +github.com/0chain/gosdk v1.8.18-0.20231109073018-b1b3c2a0899d h1:gRV8ogRwXJXQl5jJflLeZGgBDWtr+EPPd4KrKwPH15w= +github.com/0chain/gosdk v1.8.18-0.20231109073018-b1b3c2a0899d/go.mod h1:d3YLgnSKvEtZ6I9taIQotb6xcMvUKvd01JnkXS+O1jk= github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo= @@ -297,6 +299,7 @@ github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrb github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/protolambda/bls12-381-util v0.0.0-20220416220906-d8552aa452c7/go.mod h1:IToEjHuttnUzwZI5KBSM/LOOW3qLbbrHOEfp3SbECGY= +github.com/remeh/sizedwaitgroup v1.0.0 h1:VNGGFwNo/R5+MJBf6yrsr110p0m4/OX4S3DCy7Kyl5E= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= From 0e24f3578b7641ec9f8d15cc43d5137d914d5066 Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Thu, 9 Nov 2023 16:01:16 +0530 Subject: [PATCH 2/2] use multi op --- cmd/gateway/zcn/gateway-zcn.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/cmd/gateway/zcn/gateway-zcn.go b/cmd/gateway/zcn/gateway-zcn.go index 176c50744..5668c4544 100644 --- a/cmd/gateway/zcn/gateway-zcn.go +++ b/cmd/gateway/zcn/gateway-zcn.go @@ -4,8 +4,6 @@ import ( "context" "errors" "fmt" - "github.com/0chain/gosdk/constants" - "github.com/minio/minio/internal/logger" "io" "net/http" "os" @@ -14,6 +12,9 @@ import ( "sync" "time" + "github.com/0chain/gosdk/constants" + "github.com/minio/minio/internal/logger" + "github.com/0chain/gosdk/zboxcore/sdk" "github.com/minio/cli" "github.com/minio/madmin-go" @@ -493,7 +494,13 @@ func getRelativePathOfObj(refPath, bucketName string) string { func (zob *zcnObjects) MakeBucketWithLocation(ctx context.Context, bucket string, opts minio.BucketOptions) error { // Create a directory; ignore opts remotePath := filepath.Join(rootPath, bucket) - return zob.alloc.CreateDir(remotePath) + createDirOp := sdk.OperationRequest{ + OperationType: constants.FileOperationCreateDir, + RemotePath: remotePath, + } + return zob.alloc.DoMultiOperation([]sdk.OperationRequest{ + createDirOp, + }) } func (zob *zcnObjects) PutObject(ctx context.Context, bucket, object string, r *minio.PutObjReader, opts minio.ObjectOptions) (objInfo minio.ObjectInfo, err error) { @@ -640,8 +647,14 @@ func (zob *zcnObjects) CopyObject(ctx context.Context, srcBucket, srcObject, des } else { dstRemotePath = filepath.Join(rootPath, destBucket, destObject) } - - err = zob.alloc.CopyObject(srcRemotePath, dstRemotePath) + copyOp := sdk.OperationRequest{ + OperationType: constants.FileOperationCopy, + RemotePath: srcRemotePath, + DestPath: dstRemotePath, + } + err = zob.alloc.DoMultiOperation([]sdk.OperationRequest{ + copyOp, + }) if err != nil { return }