@@ -123,7 +123,7 @@ func (r *S3CopySvc) GetVersionInfo(ctx context.Context, user string, to File) ([
123123 if err != nil {
124124 return nil , fmt .Errorf ("unable to get %s storage client: %w" , to .Storage , err )
125125 }
126- objects := objstore .ObjectVersions (ctx , storageClient , to .Bucket , to .Name )
126+ objects := storageClient .ObjectVersions (ctx , to .Bucket , to .Name )
127127
128128 result := []entity.ObjectVersionInfo {}
129129 for object , err := range objects {
@@ -227,7 +227,7 @@ func (r *S3CopySvc) ClearDestination(ctx context.Context, user string, to File,
227227 return nil
228228 }
229229
230- objectIter := objstore .ObjectVersions (ctx , toClient , to .Bucket , to .Name )
230+ objectIter := toClient .ObjectVersions (ctx , to .Bucket , to .Name )
231231
232232 listErrs := []error {}
233233 namesAndVersions := []objstore.NameAndVersion {}
@@ -363,8 +363,7 @@ func (r *S3CopySvc) CopyObject(ctx context.Context, user string, from File, to F
363363 return fmt .Errorf ("unable to get from object: %w" , err )
364364 }
365365 defer fromObject .Close ()
366- // The source object can be deleted after the initial stat, before its content is requested.
367- // Requests to the source returning not found mean the object is gone: return dom.ErrNotFound as for the initial stat.
366+ // the source object can be deleted after the initial stat
368367 stat , err := fromObject .Stat ()
369368 if err != nil {
370369 if isNotFound (err ) {
@@ -401,9 +400,8 @@ func (r *S3CopySvc) CopyObject(ctx context.Context, user string, from File, to F
401400 return nil
402401}
403402
404- // sourceReader reads the source object for PutObject and keeps the error of reading it,
405- // so a failed source read is told apart from a failed destination write.
406- // It does not expose minio.Object.ReadAt, so PutObject keeps reading the source sequentially, as for *minio.Object.
403+ // sourceReader keeps the source read error to tell it apart from a destination write error.
404+ // It hides minio.Object.ReadAt so PutObject reads sequentially.
407405type sourceReader struct {
408406 obj * minio.Object
409407 err error
@@ -428,15 +426,14 @@ func (r *sourceReader) setErr(err error) {
428426 }
429427}
430428
431- // isDeleteMarkerVersion reports whether the file version is listed as a delete marker in the object versions list.
432429func (r * S3CopySvc ) isDeleteMarkerVersion (ctx context.Context , user string , file File ) (bool , error ) {
433430 client , err := r .clientRegistry .AsCommon (ctx , file .Storage , user )
434431 if err != nil {
435432 return false , fmt .Errorf ("unable to get %s storage client: %w" , file .Storage , err )
436433 }
437434 // the listing is read to the end: stopping it early leaks the minio-go listing goroutine
438435 isDeleteMarker := false
439- for object , err := range objstore .ObjectVersions (ctx , client , file .Bucket , file .Name ) {
436+ for object , err := range client .ObjectVersions (ctx , file .Bucket , file .Name ) {
440437 if errors .Is (err , objstore .ErrBucketDoesntExist ) {
441438 return false , nil
442439 }
@@ -450,7 +447,6 @@ func (r *S3CopySvc) isDeleteMarkerVersion(ctx context.Context, user string, file
450447 return isDeleteMarker , nil
451448}
452449
453- // isNotFound reports whether err is an S3 not found error response (NoSuchKey, NoSuchVersion, NoSuchBucket, etc.).
454450func isNotFound (err error ) bool {
455451 var errorResp minio.ErrorResponse
456452 return errors .As (err , & errorResp ) && (errorResp .Code == minio .NoSuchKey || errorResp .StatusCode == http .StatusNotFound )
0 commit comments