Skip to content

Commit 118dbab

Browse files
committed
code: fix grammatical errors
1 parent 650db4a commit 118dbab

File tree

15 files changed

+29
-29
lines changed

15 files changed

+29
-29
lines changed

docs/protocol.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ type WantObject struct {
360360
OID string `json:"oid"`
361361
}
362362

363-
type BatchSharedsRequest struct {
363+
type BatchShareObjectsRequest struct {
364364
Objects []*WantObject `json:"objects"`
365365
}
366366
```
@@ -391,7 +391,7 @@ type Representation struct {
391391
ExpiresAt time.Time `json:"expires_at,omitempty"`
392392
}
393393

394-
type BatchSharedsResponse struct {
394+
type BatchShareObjectsResponse struct {
395395
Objects []*Representation `json:"objects"`
396396
}
397397

modules/oss/bucket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ h = hmac.new(accesskey,
159159
Signature = base64.encodestring(h.digest()).strip()
160160
*/
161161

162-
func (b *bucket) Sharing(ctx context.Context, resourcePath string, expiresAt int64) string {
162+
func (b *bucket) Share(ctx context.Context, resourcePath string, expiresAt int64) string {
163163
u := &url.URL{
164164
Scheme: b.sharedScheme,
165165
Host: b.sharedBucketEndpoint,

modules/oss/gcs.del

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (b *gscBucket) ListObjects(ctx context.Context, prefix, continuationToken s
124124
return objects, it.PageInfo().Token, nil
125125
}
126126

127-
func (b *gscBucket) Sharing(ctx context.Context, resourcePath string, expiresAt int64) string {
127+
func (b *gscBucket) Share(ctx context.Context, resourcePath string, expiresAt int64) string {
128128
signedURL, _ := b.bucket.SignedURL(resourcePath, &storage.SignedURLOptions{Method: http.MethodGet, Expires: time.Now().Add(time.Second * time.Duration(expiresAt))})
129129
return signedURL
130130
}

modules/oss/oss.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type Bucket interface {
3535
LinearUpload(ctx context.Context, resourcePath string, r io.Reader, size int64, mime string) error
3636
DeleteMultipleObjects(ctx context.Context, objectKeys []string) error
3737
ListObjects(ctx context.Context, prefix, continuationToken string) ([]*Object, string, error)
38-
Sharing(ctx context.Context, resourcePath string, expiresAt int64) string
38+
Share(ctx context.Context, resourcePath string, expiresAt int64) string
3939
}
4040

4141
var (

modules/oss/s3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ func (b *s3Bucket) ListObjects(ctx context.Context, prefix, continuationToken st
311311
return objects, aws.ToString(out.ContinuationToken), nil
312312
}
313313

314-
func (b *s3Bucket) Sharing(ctx context.Context, resourcePath string, expiresAt int64) string {
314+
func (b *s3Bucket) Share(ctx context.Context, resourcePath string, expiresAt int64) string {
315315
o, err := b.pc.PresignGetObject(ctx, &s3.GetObjectInput{
316316
Bucket: aws.String(b.bucketName),
317317
Key: aws.String(resourcePath),

pkg/serve/httpserver/transfer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func (s *Server) BatchObjects(w http.ResponseWriter, r *Request) {
208208

209209
// POST /{namespace}/{repo}/objects/share
210210
func (s *Server) ShareObjects(w http.ResponseWriter, r *Request) {
211-
var request protocol.BatchSharedsRequest
211+
var request protocol.BatchShareObjectsRequest
212212
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
213213
renderFailureFormat(w, r.Request, http.StatusBadRequest, "decode request body error: %v", err)
214214
return
@@ -219,7 +219,7 @@ func (s *Server) ShareObjects(w http.ResponseWriter, r *Request) {
219219
}
220220
defer rr.Close()
221221

222-
response := &protocol.BatchSharedsResponse{
222+
response := &protocol.BatchShareObjectsResponse{
223223
Objects: make([]*protocol.Representation, 0, len(request.Objects)),
224224
}
225225
odb := rr.ODB()
@@ -232,7 +232,7 @@ func (s *Server) ShareObjects(w http.ResponseWriter, r *Request) {
232232
}
233233
want := plumbing.NewHash(o.OID)
234234
// oss shared download link
235-
ro, err := odb.Sharing(r.Context(), want, expiresAt)
235+
ro, err := odb.Share(r.Context(), want, expiresAt)
236236
if err != nil {
237237
s.renderError(w, r, err)
238238
return

pkg/serve/odb/odb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type DB interface {
2525
Push(ctx context.Context, oid plumbing.Hash) error // Push object to OSS
2626
WriteDirect(ctx context.Context, oid plumbing.Hash, r io.Reader, size int64) (int64, error)
2727
Stat(ctx context.Context, oid plumbing.Hash) (*oss.Stat, error)
28-
Sharing(ctx context.Context, oid plumbing.Hash, expiresAt int64) (*Representation, error)
28+
Share(ctx context.Context, oid plumbing.Hash, expiresAt int64) (*Representation, error)
2929
}
3030

3131
type ODB struct {

pkg/serve/odb/oss.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type Representation struct {
4848
ExpiresAt int64
4949
}
5050

51-
func (o *ODB) Sharing(ctx context.Context, oid plumbing.Hash, expiresAt int64) (*Representation, error) {
51+
func (o *ODB) Share(ctx context.Context, oid plumbing.Hash, expiresAt int64) (*Representation, error) {
5252
resourcePath := ossJoin(o.rid, oid)
5353
si, err := o.bucket.Stat(ctx, resourcePath)
5454
if err != nil {
@@ -57,7 +57,7 @@ func (o *ODB) Sharing(ctx context.Context, oid plumbing.Hash, expiresAt int64) (
5757
}
5858
return nil, err
5959
}
60-
href := o.bucket.Sharing(ctx, resourcePath, expiresAt)
60+
href := o.bucket.Share(ctx, resourcePath, expiresAt)
6161
return &Representation{
6262
Href: href,
6363
Size: si.Size,

pkg/serve/protocol/protocol.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ type WantObject struct {
103103
Path string `json:"path,omitempty"`
104104
}
105105

106-
type BatchSharedsRequest struct {
106+
type BatchShareObjectsRequest struct {
107107
Objects []*WantObject `json:"objects"`
108108
}
109109

@@ -115,7 +115,7 @@ type Representation struct {
115115
ExpiresAt time.Time `json:"expires_at,omitempty"`
116116
}
117117

118-
type BatchSharedsResponse struct {
118+
type BatchShareObjectsResponse struct {
119119
Objects []*Representation `json:"objects"`
120120
}
121121

pkg/serve/sshserver/command_objects.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (s *Server) GetObject(e *Session, oid plumbing.Hash, offset int64) int {
161161
}
162162

163163
func (s *Server) ShareObjects(e *Session) int {
164-
var request protocol.BatchSharedsRequest
164+
var request protocol.BatchShareObjectsRequest
165165
if err := json.NewDecoder(e).Decode(&request); err != nil {
166166
return e.ExitFormat(400, "decode request body error: %v", err)
167167
}
@@ -171,7 +171,7 @@ func (s *Server) ShareObjects(e *Session) int {
171171
}
172172
defer rr.Close()
173173

174-
response := &protocol.BatchSharedsResponse{
174+
response := &protocol.BatchShareObjectsResponse{
175175
Objects: make([]*protocol.Representation, 0, len(request.Objects)),
176176
}
177177
odb := rr.ODB()
@@ -183,7 +183,7 @@ func (s *Server) ShareObjects(e *Session) int {
183183
}
184184
want := plumbing.NewHash(o.OID)
185185
// oss shared download link
186-
ro, err := odb.Sharing(e.Context(), want, expiresAt)
186+
ro, err := odb.Share(e.Context(), want, expiresAt)
187187
if err != nil {
188188
return e.ExitError(err)
189189
}

0 commit comments

Comments
 (0)