Skip to content
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.

os agnostic #12

Merged
merged 9 commits into from
Nov 3, 2017
Merged

os agnostic #12

merged 9 commits into from
Nov 3, 2017

Conversation

richardschneider
Copy link
Contributor

@richardschneider richardschneider commented Oct 31, 2017

The key path is always OS agnostic and is separated with a /. This allows callers to use the standard key name without having to worry about the runtime OS.

These changes are an improvement on #11 and get all tests to work.

IMHO: #5 is wrong.

Hopefully this will help js-ipfs move forwards on a window platform (ipfs/js-ipfs#1017, ipfs/js-ipfs-repo#144 and ipfs/js-datastore-core#2)

@daviddias
Copy link
Member

@richardschneider could you confirm that this feature does not break go-ipfs interop? @dryajov might be able to help :)

@dryajov
Copy link
Member

dryajov commented Nov 2, 2017

I think this PR makes a lot of sense, what I'm not sure about is why the initial os specific change was introduced and I haven't had the time to dig into the code to figure it out. Perhaps, @dignifiedquire has some insights as to why the original change was introduced?

@diasdavid I can make sure that interop with Go doesn't break :)

@richardschneider
Copy link
Contributor Author

richardschneider commented Nov 2, 2017

I'm pretty sure this does not break any go-ipfs interop, I'm using the new code with js-datastore-fs which has a test for interop with go and it passes.

@Kubuxu
Copy link
Member

Kubuxu commented Nov 2, 2017

EDIT: I read this PR wrong. It removes os specific component from the interface-datastore.


The repo should also have interop from Windows to Linux and back. So please check if keys used in for example leveldb are the same on both those systems. For me it seems that platform specific stuff should be done in flatfs and other datastore implementations that touch file system instead of here but I might be wrong.

@richardschneider
Copy link
Contributor Author

@Kubuxu Is this comment directed at me? If so I'm not sure what ur asking.

@dryajov
Copy link
Member

dryajov commented Nov 2, 2017

@Kubuxu This is part of making js-ipfs run on windows. So far I don't think we have any testing going on windows, but we'll keep this in mind - thanks!

@richardschneider I believe, this might potentially require changes to each implementation to account for path conversions for each os? I'll spend some time today looking at the code as well to have a better idea of what else is required.

@Kubuxu
Copy link
Member

Kubuxu commented Nov 2, 2017

What I am saying is:
datastore can be backed by multiple types of repos: leveldb, badgerds (in Go) and flatfs (and many more). Keys should be exactly the same in all of those repos on all architectures and flatfs (as it currently is the only repo that touches file system so its keys are affected by different separator) should do key translation.

@Kubuxu
Copy link
Member

Kubuxu commented Nov 2, 2017

The usage of path.sep in key "class" might had been invalid "try" for Windows compatibility that isn't needed in this place from the begging.

@whyrusleeping could you take a look at this

I didn't write this code and I don't understand fully how js's ipfs stack works but something here smells fishy.

@richardschneider
Copy link
Contributor Author

richardschneider commented Nov 2, 2017

@dryajov The PR is all about making key paths os-agnostic, always using '/'. I've applied it to js-datastore-core and js-datastore-fs and they now work on windows.

@Kubuxu
Copy link
Member

Kubuxu commented Nov 2, 2017

@richardschneider aghr, I always looked at this PR late into the night. You are right, you are removing the usage of path.sep here.

@dryajov
Copy link
Member

dryajov commented Nov 2, 2017

@Kubuxu that makes sense. In that case I have a couple of questions:

  • Are keys os specific in go?
    • if so, what is the reasoning behind that?

My current understanding of datastore keys is that they should be OS agnostic, and the underlying implementation (fs, leveldb, badger, etc) would convert the hierarchical key to a representation that is specific to its underlying store, i.e. datastore-fs, should take care of making the key separators into some sort of fs structure. (Take this with a grain of salt, I have not spent much time looking into either the implementations nor the spec, so my reasoning might be a bit of...)

@dryajov dryajov closed this Nov 2, 2017
@dryajov dryajov reopened this Nov 2, 2017
@Kubuxu
Copy link
Member

Kubuxu commented Nov 2, 2017

@richardschneider please accept my apology for the mess I caused in this PR. I didn't notice that it was removing the path.sep usage here and making things as they should be.

@dryajov
Copy link
Member

dryajov commented Nov 2, 2017

uppps... accidentally closed the PR, ignore.

@Kubuxu
Copy link
Member

Kubuxu commented Nov 2, 2017

@dryajov keys have the same separator on all platforms in Go /. The flatfs (sharding datastore?) uses system specific function to join paths but it also never receives key with multiple path elements.

What it receives currently is /CIQEMFC2HN3HPCUI6ZM2BVVUQ6VXLWNJVQZSCW3E6BNL2GT25PMS22I where the long string is base32 encoded bytes of CID (with no multibase prefix).

@Kubuxu
Copy link
Member

Kubuxu commented Nov 2, 2017

datastore-fs, should take care of making the key separators into some sort of fs structure.

Yes. This PR is correct in this regard.

Side note: in last few days I have misinterpreted quite few PRs for some reason.

@dryajov
Copy link
Member

dryajov commented Nov 2, 2017

@Kubuxu no worries at all, thanks for jumping in 👍

@richardschneider
Copy link
Contributor Author

richardschneider commented Nov 2, 2017

why is appveyor build not working? Seems to be some infrastructure issue. It was working a few days ago, https://ci.appveyor.com/project/dignifiedquire/interface-datastore/build/27

@@ -54,7 +54,8 @@
"David Dias <[email protected]>",
"Erin Dachtler <[email protected]>",
"Juan Batiz-Benet <[email protected]>",
"dignifiedquire <[email protected]>"
"dignifiedquire <[email protected]>",
"Richard Schneider <[email protected]>"
Copy link
Member

Choose a reason for hiding this comment

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

no need to do this, will be picked up from the commits on release

@dignifiedquire
Copy link
Member

The code looks good to me, but before we merge, lets make sure to have a windows specific version of https://github.com/ipfs/js-ipfs-repo/blob/master/test/interop-test.js using this code to make sure things work as expected

@richardschneider
Copy link
Contributor Author

@dignifiedquire okay will fork and test

@richardschneider
Copy link
Contributor Author

@dignifiedquire tried running tests for js-ipfs-repo it fails with an error in levelup

 1) IPFS Repo Tests on on Node.js default "before all" hook:
: The filename, directory name, or volume label syntax is incorrect.s-ipfs-repo\test\test-repo-for-1509616898591\datastore/MANIFEST-000052

      at c:\Users\Owner\Documents\GitHub\js-ipfs-repo\node_modules\levelup\lib\levelup.js:117:34
      at c:\Users\Owner\Documents\GitHub\js-ipfs-repo\node_modules\leveldown\node_modules\abstract-leveldown\abstract-leveldown.js:39:16

Looks like levelup needs some TLC for windows.

@dignifiedquire
Copy link
Member

dignifiedquire commented Nov 2, 2017 via email

@richardschneider
Copy link
Contributor Author

I got this error when running from the source in the repo. My interface-datastore code is NOT is not being used. See ipfs/js-ipfs-repo#144

@dryajov
Copy link
Member

dryajov commented Nov 2, 2017

@dignifiedquire I believe that this path normalization should happen at the level of the specific datastore implementation, i.e. https://github.com/ipfs/js-datastore-core/blob/master/src/shard.js in this case?

@richardschneider
Copy link
Contributor Author

@dryajov I tested js-datastore-core with this PR and every test passed.

However, the interface-datastore.tests against a sharding store were disabled because not all of the query options where implemented in the sharding store. I've corrected this in PR ipfs/js-datastore-core#3

@richardschneider
Copy link
Contributor Author

@dryajov @diasdavid @dignifiedquire is there anyway you guys can progress PR or ask for changes. I have a number of the PRs for windows that are waiting on this. Ideally a new patch release to NPM would be great.

@dignifiedquire
Copy link
Member

dignifiedquire commented Nov 3, 2017 via email

@dryajov
Copy link
Member

dryajov commented Nov 3, 2017

@richardschneider let me do a quick review and see if @diasdavid or @dignifiedquire can do a release.

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

@richardschneider
Copy link
Contributor Author

@diasdavid or @dignifiedquire anyone want to release?

@whyrusleeping
Copy link
Member

whyrusleeping commented Nov 3, 2017 via email

@daviddias daviddias changed the base branch from master to windows-interop November 3, 2017 09:04
@daviddias
Copy link
Member

@richardschneider thank you for being awesome and pushing the Windows support throughout multiple modules!

I'm going to start reviewing all of this and to make it easier in all of us, I'm going to merge this PR into a direct branch of this repo. I've invited you to the JavaScript Team of IPFS so that you can contribute to the branch too, Welcome to the party 🎉

@daviddias daviddias merged commit ef4da75 into ipfs:windows-interop Nov 3, 2017
@richardschneider richardschneider deleted the os-agnostic branch November 3, 2017 09:26
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.

6 participants