-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add large-object support for CopyObject API #644
Conversation
API change proposal:
Providing explicit source bucket and object makes it easier for user to not have to format it as "/bucket/object". Data type and methods: // Not exported so that user has to use an initialization function
type copySourceInfo struct {
copyConditions map[string]string
byteRangeStart int64
byteRangeEnd int64
}
// To allocate map and initialize range
func NewCopySourceInfo() copySourceInfo {}
// funcs to set copy conditions.
func (c *copySourceInfo) SetMatchETag(etag string) error {}
func (c *copySourceInfo) SetMatchETagExcept(etag string) error {}
func (c *copySourceInfo) SetUnmodified(modTime time.Time) error {}
func (c *copySourceInfo) SetModified(modTime time.Time) error {}
func (c *copySourceInfo) SetByteRange(start, end int64) error {}
// internal utils
func (c *copySourceInfo) getRangeSize() int64 {}
func (c *copySourceInfo) duplicate() *copySourceInfo {} |
To keep backward compatibility we can introduce a new API, we now have projects dependent on Will discuss this with @abperiasamy and see where we go from there. |
return c.byteRangeEnd - c.byteRangeStart + 1 | ||
} | ||
|
||
func (c *CopyConditions) duplicate() *CopyConditions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call this clone()
or cloneCopyConditions
in Go style.
} | ||
return parts[1], parts[2], nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment necessary..
@@ -70,3 +102,91 @@ func (c Client) CopyObject(bucketName string, objectName string, objectSource st | |||
// Return nil on success. | |||
return nil | |||
} | |||
|
|||
func getObjectSource(src string) (bucket string, object string, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment necessary.. and a test case..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments, overall looks good.
if err != nil { | ||
return err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray newline?
cpCond.byteRangeStart, cpCond.byteRangeEnd, srcInfo.Size)) | ||
} | ||
|
||
copySize := srcByteRangeSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment explaining how an empty range is interpreted as the entire object would provide context for future.
func (c *CopyConditions) getRangeSize() int64 { | ||
if c.byteRangeStart < 0 { | ||
// only happens if byte-range was not set by user | ||
return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably it is better to set this to -1 to say unknown. Probably zero is a valid value.
if start < 0 || end < start { | ||
return ErrInvalidArgument("Range start less than 0 or range end less than range start.") | ||
} | ||
if end-start+1 < 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this condition is useless,
Here we are already sure that start <= end
:
start <= end
<=> 0 <= end - start
<=> 1 <= end - start + 1
,
so we will never have end-start+1 < 1
|
||
// Update the source range header value. | ||
headers.Set("x-amz-copy-source-range", | ||
fmt.Sprintf("bytes:%d-%d", pCond.byteRangeStart, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong btw - it should be bytes=%d-%d
Is this still blocked? |
Yes not discussed yet. |
@donatello can you update this and incorporate usage of requestHeaders instead of copyConditions . Which would expand the scope of this. |
@donatello can you incorporate the request-headers.go changes to CopyObject() just like how we did with GetObject() .This would be a breaking change we will bump up the tag so that the users who have referenced using our tags atleast can understand why this change. |
@donatello, @harshavardhana is there anything I can do to help? |
@tejaycar We plan to get this resolved by next week. We are busy with the Minio server release at this time. |
Awesome. Thanks guys.
…On Jun 8, 2017 1:02 PM, "Aditya Manthramurthy" ***@***.***> wrote:
@tejaycar <https://github.com/tejaycar> We plan to get this resolved by
next week. We are busy with the Minio server release at this time.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#644 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADqwzK9gCNi5cUj-jujxrK654Mrs0oQOks5sCEVEgaJpZM4M4tp5>
.
|
@donatello I don't mean to bug, but do you have any update to offer on this? I'm not trying to push, just trying to plan accordingly. |
@tejaycar I am actively working on this, and hope to have a PR today. I would venture to say that it might get merged by the end of the week after reviews and testing. |
Once again, thank you. I appreciate the update.
…On Mon, Jun 19, 2017 at 1:32 PM, Aditya Manthramurthy < ***@***.***> wrote:
@donatello <https://github.com/donatello> I don't mean to bug, but do you
have any update to offer on this? I'm not trying to push, just trying to
plan accordingly.
@tejaycar <https://github.com/tejaycar> I am actively working on this,
and hope to have a PR today. I would venture to say that it might get
merged by the end of the week after reviews and testing.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#644 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADqwzF7LnGfI3104fu0qsIiPOeVGdfTnks5sFszqgaJpZM4M4tp5>
.
|
We are bringing large object copy support via a more flexible This PR is thus superseded by #715. Closing as obsolete. |
This patch is up for early review.
Context of the change is at #617
The byte-range for the source object has been added into CopyConditions type - ideally the
CopyConditions
type should be calledCopySourceInfo
and it should have the copy-conditions, copy-source and the optional copy-byte-range. However, the changes in this patch aim to keep backwards compatibility.The one wrinkle is the
NewCopyConditions
method - it is now the preferred method to create aCopyConditions{}
instance as it initializes the byte-range to -1 (indicating that the byte range is not specified by the user).This is as yet untested - hoping to get some input about the interface improvement to be done.