Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

fix size-0 chunker bug #9

Merged
merged 2 commits into from
Oct 1, 2018
Merged

fix size-0 chunker bug #9

merged 2 commits into from
Oct 1, 2018

Conversation

kjzz
Copy link
Contributor

@kjzz kjzz commented Sep 29, 2018

fix bug go-ipfs #5542

@@ -23,6 +26,8 @@ func FromString(r io.Reader, chunker string) (Splitter, error) {
size, err := strconv.Atoi(sizeStr)
if err != nil {
return nil, err
} else if size <= 0 {
return nil, ErrSize
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine. I think it would be better though to have NewSizeSplitter verify its arguments are sane and return an error. But since NewRabinMinMax does not return an error it is not that big of a deal.

Copy link
Contributor

@kevina kevina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We could do some additional cleanup later like have NewSizeSplitter and NewRabinMinMax check if there arguments are sane and return errors instead, but we can do that in a separate commit.

@kjzz
Copy link
Contributor Author

kjzz commented Sep 29, 2018

@kevina yeah ,if we change to NewSizeSplitter(r io.Reader, size int64) (Splitter,error) ,i will influence other package who use this function.It is a compromise to fix this bug.
WDYT?
And if you decide to do this , i am willing to di it. You can assign it to me,Thx a lot.

@Stebalien Stebalien merged commit d344117 into ipfs:master Oct 1, 2018
@Stebalien
Copy link
Member

You're both right. Yes, it's a breaking change but the current behavior is buggy anyways so I'd make the change and fix dependent packages.

@kjzz kjzz deleted the zkj/chunker branch October 2, 2018 01:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants