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

fix: Windows support #7

Merged
merged 8 commits into from
Nov 4, 2017
Merged

fix: Windows support #7

merged 8 commits into from
Nov 4, 2017

Conversation

daviddias
Copy link
Member

No description provided.

@ghost ghost assigned daviddias Nov 3, 2017
@ghost ghost added the status/in-progress In progress label Nov 3, 2017
Copy link
Member Author

@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.

LGTM!

src/index.js Outdated
@@ -136,7 +136,9 @@ class FsDatastore {
throw new Error(`Invalid extension: ${path.extname(file)}`)
}

return new Key(file.slice(this.path.length, -ext.length))
let keyname = file.slice(this.path.length, -ext.length)
Copy link
Member Author

Choose a reason for hiding this comment

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

s/let/const

Copy link
Contributor

Choose a reason for hiding this comment

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

Its an age thing. I come from AI/functional programming. I only use const for scalars. Consider my hand slapped.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a newbie to organisational github. How to I change a PR that you submitted? I'm use to being on the other side.

Copy link
Member Author

Choose a reason for hiding this comment

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

The simpler way is to clone again.

git clone git@github.com:ipfs/js-datastore-fs.git
cd js-datastore-fs
git checkout windows-interop
# do your changes
git add <files changed>
git commit -m "message"
git push origin windows-interop

src/index.js Outdated
if (q.filters != null) {
filters = filters.concat(q.filters)
tasks = tasks.concat(q.filters.map(f => asyncFilter(f)))
Copy link
Member Author

Choose a reason for hiding this comment

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

Please use () for ((f) => asyncFilter(f))

Copy link
Contributor

@richardschneider richardschneider Nov 3, 2017

Choose a reason for hiding this comment

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

Why? I've noticed it all over the code and think its just more code, less is better.

Do you have a published coding standard?

Copy link
Member Author

Choose a reason for hiding this comment

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

We do have contributing guidelines and linting rules (https://github.com/ipfs/community/blob/master/js-project-guidelines.md) but it is a bit outdated.

I do agree that less is more, but sometimes less means "I need to be familiar with some new ES6 thing" which turns out to be more. We kind of follow a slow transition path towards new ES features, we postpone anything that we consider ourselves that it is not as intuitive (yet) or that doesn't really add any urgent value.

Copy link
Member

@dignifiedquire dignifiedquire Nov 3, 2017

Choose a reason for hiding this comment

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

in this case there is a better way to write this actually:

tasks = tasks.concat(q.filters.map(asyncFilter))

no need to wrap in another arrow function as far as I can telll

// TODO: depends on sharding query fix
describe.skip('interface-datastore (sharding(fs))', () => {

describe('interface-datastore (sharding(fs))', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

RAD!

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe not so rad, see #6, maybe the test belongs somewhere else.

Copy link
Member

Choose a reason for hiding this comment

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

These tests do belong here, to make sure our implementation of fs passes the interface-datastore tests with sharding. Otherwise this repo can break things without ci noticing it

Copy link
Contributor

Choose a reason for hiding this comment

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

okay, so I'll move the various dependencies into devDependencies.

src/index.js Outdated
let pattern =
path.join(this.path, prefix, '*' + this.opts.extension)
.split(path.sep)
.join('/')
Copy link
Member

@dignifiedquire dignifiedquire Nov 3, 2017

Choose a reason for hiding this comment

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

Using a regex to do a replace should be more efficient than splitting into an array and rejoining. I.e.

// at the top of the file
const reg = new RegExp(path.sep , 'g')

path.join(..).replace(reg, '/')

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure? My feeling is that regex is very expensive, compared to a few bytes (128) on the heap.

Copy link
Member

Choose a reason for hiding this comment

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

Well split + join means you are allocating a new array and a new string, vs if you use a regex it only allocates a new string for the replacement.

Copy link
Member

Choose a reason for hiding this comment

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

and if you are unlucky the code path for .split could end up allocating new strings for each part, so array + x string allocations for the individual parts

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah but regex needs to do parsing and then build a state table.

This is about to turn into a religious war that I want to avoid. So lets kiss and makeup.

Copy link
Member

@dignifiedquire dignifiedquire Nov 3, 2017

Choose a reason for hiding this comment

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

fair enough, lets worry about it once it becomes an actual perf issue

@@ -91,7 +91,7 @@ describe('FsDatastore', () => {
})

it('query', (done) => {
const fs = new FsStore(path.join(__dirname, 'test-repo/blocks'))
const fs = new FsStore(path.join(__dirname, 'test-repo', 'blocks'))
Copy link
Member

Choose a reason for hiding this comment

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

nice, but not needed, path.join actually takes care of the normalisation already.

path.join('a/b', 'c') === path.join('a', 'b', 'c')

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes you are right. I was just being paranoid about slashes when trying to get it working on windows.

Copy link
Member

@victorb victorb Nov 3, 2017

Choose a reason for hiding this comment

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

Leaving out the platform-specific dividers makes it easier for everyone on platforms that don't use forward-slashes though. I think this is a good change.

Copy link
Member

@dryajov dryajov left a comment

Choose a reason for hiding this comment

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

LGTM

@dryajov
Copy link
Member

dryajov commented Nov 3, 2017

@richardschneider there are some linting issues as well as failing tests, are you taking a look at those?

@richardschneider
Copy link
Contributor

@diasdavid I need your magic to make CI and flow happy

@diasdavid @dryajov I need to release ipfs/js-datastore-core#6, what is the process?

@codecov
Copy link

codecov bot commented Nov 4, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@1507a6b). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master       #7   +/-   ##
=========================================
  Coverage          ?   97.89%           
=========================================
  Files             ?        1           
  Lines             ?       95           
  Branches          ?        0           
=========================================
  Hits              ?       93           
  Misses            ?        2           
  Partials          ?        0
Impacted Files Coverage Δ
src/index.js 97.89% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1507a6b...f551d30. Read the comment docs.

@daviddias daviddias merged commit e7c8f25 into master Nov 4, 2017
@ghost ghost removed the status/in-progress In progress label Nov 4, 2017
@daviddias daviddias deleted the windows-interop branch November 4, 2017 09:14
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.

5 participants