Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

complete files.stat with the 'with-local' option #227

Merged
merged 2 commits into from
Mar 12, 2018

Conversation

MichaelMure
Copy link
Contributor

@MichaelMure MichaelMure commented Feb 28, 2018

Following ipfs/kubo#4638, this new option is present in go-ipfs that enable to know if and how much of a dag is present locally.

Now, in the go-ipfs's http API, WithLocality, Local and SizeLocal in the answer are not present when with-local is not active. I chose to set default values in the javascript object response, but it could also be done the same way with no values present at all. Which would be best ?

Copy link
Contributor

@daviddias daviddias left a comment

Choose a reason for hiding this comment

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

@MichaelMure Could you write tests for these options?

SPEC/FILES.md Outdated
@@ -618,6 +618,7 @@ Where:
- `options` is an optional Object that might contain the following keys:
- `hash` is a Boolean value to return only the hash.
- `size` is a Boolean value to return only the size.
- `with-local` is a Boolean value to compute the amount of the dag that is local, and if possible the total size.
Copy link
Contributor

Choose a reason for hiding this comment

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

When options have -, we translate them to camel case. withLocal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do, but it's currently not respected in js-ipfs-api. For instance: https://github.com/ipfs/js-ipfs-api/blob/master/test/files.spec.js#L93

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems that one passed by review. That said, we still want to keep the camelCase version and support the dash for backwards compatibility

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see that lodash is used exactly once in js-ipfs-api. Nothing against using opts = _.mapKeys(opts, (v, k) => _.kebabCase(k)) ?

That would support both version and some more easily.

it('stat withLocal file', (done) => {
if (!withGo) {
console.log('Not supported in js-ipfs yet')
return done()
Copy link
Contributor

Choose a reason for hiding this comment

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

call this.skip(). You will have to replace the arrow function by regular function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the way it's done in all the codebase. Do you prefer to change that here or in a single pass in another PR ?

Copy link
Contributor

Choose a reason for hiding this comment

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

can you change the others first in a PR and update this one to match? thank you :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if (!withGo) {
console.log('Not supported in js-ipfs yet')
return done()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above.

js/src/files.js Outdated
it('stat outside of mfs', () => {
if (!withGo) {
console.log('Not supported in js-ipfs yet')
return done()
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above.

@MichaelMure
Copy link
Contributor Author

@diasdavid I changed for this.skip() as well so it should be fine now

Copy link
Contributor

@daviddias daviddias left a comment

Choose a reason for hiding this comment

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

Thank you @MichaelMure :)

@daviddias daviddias merged commit 5969fed into ipfs-inactive:master Mar 12, 2018
vmx added a commit that referenced this pull request Mar 13, 2018
@vmx
Copy link
Contributor

vmx commented Mar 13, 2018

This PR broke most of the .stat tests run by js-ipfs-api: https://ci.ipfs.team/blue/organizations/jenkins/IPFS%2Fjs-ipfs-api/detail/get-ci-green/1/tests/

@MichaelMure Can you please have a look?

@daviddias
Copy link
Contributor

@vmx you will need ipfs-inactive/js-ipfs-http-client#695. Wanna update deps there?

This is one of the reasons why I asked you for a issue that lists all the PR to make js-ipfs-api tests. There are so many PR's in flight that is hard to manage.

vmx added a commit that referenced this pull request Mar 13, 2018
vmx added a commit that referenced this pull request Mar 15, 2018
@MichaelMure
Copy link
Contributor Author

@vmx Thank for taking care of that.

@vmx
Copy link
Contributor

vmx commented Mar 16, 2018

@MichaelMure It wasn't me, @diasdavid fixed those tests.

@MichaelMure
Copy link
Contributor Author

Errr, thanks @diasdavid ^^

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.

None yet

4 participants