Skip to content
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

implement an ipfs cat --length flag #4553

Merged
merged 3 commits into from
Jan 12, 2018
Merged

implement an ipfs cat --length flag #4553

merged 3 commits into from
Jan 12, 2018

Conversation

Stebalien
Copy link
Member

fixes #4085

(because we too many open bugs dammit)

@ghost ghost assigned Stebalien Jan 6, 2018
@ghost ghost added the status/in-progress In progress label Jan 6, 2018
fixes #4085

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
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.

Fix codeclimate issue, otherwise LGTM.

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.

Some portability suggestions.


test_expect_success "ipfs cat multiple hashes with offset and length looks good" '
echo " Worlds!" >expected &&
echo -n "Hello " >>expected &&
Copy link
Contributor

@kevina kevina Jan 6, 2018

Choose a reason for hiding this comment

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

I would use printf "Worlds!\nHello ".

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that is you try this in bash on the command line this will fail as '!' has special meaning in bash when history expansion in enabled. This is disabled by default in scripts so it won't cause a problem.

'

test_expect_success "ipfs cat with length output looks good" '
echo -n "Hello Wo" >expected &&
Copy link
Contributor

@kevina kevina Jan 6, 2018

Choose a reason for hiding this comment

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

Note the -n flag is not universally supported by all shells (for example on the mac). It is better to use printf which is more portable. In this case it will be

  printf "Hello Wo" >expected &&

See https://apple.stackexchange.com/questions/173836/why-echo-n-doesnt-work-in-this-script-on-mac-terminal

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
@Stebalien
Copy link
Member Author

@kevina the code climate issue is a commands error style issue (and is significantly more pervasive). The error I added mimics the existing error so I'd like to leave it that way for now. We should go though these errors and fix them all at once at some point.

@kevina
Copy link
Contributor

kevina commented Jan 8, 2018

@Stebalien that doesn't bother me if @whyrusleeping is fine with it also.

@@ -50,7 +51,20 @@ var CatCmd = &cmds.Command{
return
}

readers, length, err := cat(req.Context(), node, req.Arguments(), int64(offset))
max, found, err := req.Option("length").Int()
Copy link
Member

Choose a reason for hiding this comment

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

USE int64. THIS COULD OVERFLOW

Copy link
Member

Choose a reason for hiding this comment

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

I don't see a int64 option in go-ipfs-cmdkit, we could use a uint instead? We could also add a new option if not.

Copy link
Member

Choose a reason for hiding this comment

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

I was really just giving @Stebalien crap, he was sitting behind me while i reviewed this and pointed out that this should be an int64

@whyrusleeping whyrusleeping merged commit b768fb1 into master Jan 12, 2018
@whyrusleeping whyrusleeping deleted the fix/4085 branch January 12, 2018 17:53
@ghost ghost removed the status/in-progress In progress label Jan 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Partial Read / Seeking without downloading the complete file
4 participants