MCPcopy Create free account
hub / github.com/AbelChe/evil_minio / CopyObjectPart

Method CopyObjectPart

cmd/disk-cache.go:1116–1156  ·  view source on GitHub ↗

CopyObjectPart behaves similar to PutObjectPart - caches part to upload dir if writethrough mode is enabled.

(ctx context.Context, srcBucket, srcObject, dstBucket, dstObject, uploadID string, partID int, startOffset int64, length int64, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions)

Source from the content-addressed store, hash-verified

1114
1115// CopyObjectPart behaves similar to PutObjectPart - caches part to upload dir if writethrough mode is enabled.
1116func (c *cacheObjects) CopyObjectPart(ctx context.Context, srcBucket, srcObject, dstBucket, dstObject, uploadID string, partID int, startOffset int64, length int64, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (pi PartInfo, e error) {
1117 copyObjectPartFn := c.InnerCopyObjectPartFn
1118 dcache, err := c.getCacheToLoc(ctx, dstBucket, dstObject)
1119 if err != nil {
1120 // disk cache could not be located,execute backend call.
1121 return copyObjectPartFn(ctx, srcBucket, srcObject, dstBucket, dstObject, uploadID, partID, startOffset, length, srcInfo, srcOpts, dstOpts)
1122 }
1123
1124 if !c.commitWritethrough && !c.commitWriteback {
1125 return copyObjectPartFn(ctx, srcBucket, srcObject, dstBucket, dstObject, uploadID, partID, startOffset, length, srcInfo, srcOpts, dstOpts)
1126 }
1127 if err := dcache.uploadIDExists(dstBucket, dstObject, uploadID); err != nil {
1128 return copyObjectPartFn(ctx, srcBucket, srcObject, dstBucket, dstObject, uploadID, partID, startOffset, length, srcInfo, srcOpts, dstOpts)
1129 }
1130 partInfo, err := copyObjectPartFn(ctx, srcBucket, srcObject, dstBucket, dstObject, uploadID, partID, startOffset, length, srcInfo, srcOpts, dstOpts)
1131 if err != nil {
1132 return pi, toObjectErr(err, dstBucket, dstObject)
1133 }
1134 go func() {
1135 isSuffixLength := false
1136 if startOffset < 0 {
1137 isSuffixLength = true
1138 }
1139
1140 rs := &HTTPRangeSpec{
1141 IsSuffixLength: isSuffixLength,
1142 Start: startOffset,
1143 End: startOffset + length,
1144 }
1145 // fill cache in the background
1146 bReader, bErr := c.InnerGetObjectNInfoFn(GlobalContext, srcBucket, srcObject, rs, http.Header{}, readLock, ObjectOptions{})
1147 if bErr != nil {
1148 return
1149 }
1150 defer bReader.Close()
1151 // avoid cache overwrite if another background routine filled cache
1152 dcache.PutObjectPart(GlobalContext, dstBucket, dstObject, uploadID, partID, bReader, length, ObjectOptions{UserDefined: getMetadata(bReader.ObjInfo)})
1153 }()
1154 // Success.
1155 return partInfo, nil
1156}
1157
1158// CompleteMultipartUpload - completes multipart upload operation on the backend. If writethrough mode is enabled, this also
1159// finalizes the upload saved in cache multipart dir.

Callers

nothing calls this directly

Calls 6

getCacheToLocMethod · 0.95
toObjectErrFunction · 0.85
getMetadataFunction · 0.85
uploadIDExistsMethod · 0.80
CloseMethod · 0.65
PutObjectPartMethod · 0.65

Tested by

no test coverage detected