-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix path parser in add command #1933
Conversation
this LGTM -- cc @rht this should be changed in dev0.4.0 too. |
can someone else with windows confirm this works? (we dont yet have windows CI) |
we need a windows CI -- ipfs/infra#110 |
@djdv what about the case for Also, optionally, if you can possibly refactor How many test in windows fail before/after the PR? |
It seems like only files underneath a directory are being formed correctly with the change. I'll have to look into this and compare with the behavior on other platforms, I'm not sure if that directory hash is intended to exist on multiple file adds without the -w argument, need clarification on that. That's the only instance of .Split in add.go so I've changed it to be .Base. There appears to be one less failed test with this change however I don't think I'm getting the count right, I'm running |
You're describing the #1878 case, which should be fixed by
Right, though I was referring to the entire codebase. There are two more in
There is no windows option in travis yet, so we need a real and breathing windows machine for now. |
Looks like this statement referred to the test you did before the |
@rht |
Woops, I'm being a bit hasty. Here are the logs:
Due to the way Windows cmd handles "*.go" I can't run those make files "natively" but I can inside of mingw bash, however I don't know how to pass the "nofuse" build constraint to the go tool unless I edit the makefiles.
That seems to be the case, 4c300d9 - e849262 only fixed filenames for files under a directory. Explore the hashes below and compare with the tree in #1922 to see what I mean. ipfs revision, command, output as ipfs hash f36ada8 : e849262 : Notice the level 3 files appearing in the root of the structure and the filenames of those files, the ones inside of the actual directory seem to be fixed though compared to before. I'm not sure what's causing that to happen. -Edit- -Edit 2015-11-07- |
I checked the log, the only path error is To summarize the filename cases:
@djdv https://github.com/ipfs/go-ipfs/blob/master/commands/files/serialfile.go#L72 is where each file's filename is created during the recursive add. I wonder if applying Edit: s/either or both of the/the second/ |
@rht In addition I'm getting an inconsistent error count on my tests, it seems I am getting between 33-38 failures on the same revision(both in the origin and this fork) , I'll have to log several runs and find the discrepancies, unfortunately the tests take some time on my machine. |
@djdv I went through the I found a small bug, that https://github.com/ipfs/go-ipfs/blob/master/commands/cli/parse.go#L360 needs to be wrapped with If only there are further cases to characterize the err. Whether it is caused by the cli parse, or the recursive add. Yes, the test failures in #959 were reported to vary as well. |
Latest commit is just a squashed version of all previous commits with the addition of cleaning the input along with a change related to gateway_handler.go. A previous commit used serialfile.go is unaltered for now since the suggested change seems to have no effect, further testing required. Worth noting is the edit to a comment of mine above, edited 2015-11-07 the previous (as well as this) commit resulted in the same hash for both the relative and absolute command which is a step in the right direction. As it stands right now for the directory structure in #1922 we get the following hash on Windows: Issue is still unresolved, this is just a status update mainly to show the target result/hash for a recursive add.
I intend to run the binary through GDB sometime soon to see what values are at various times as well as see the code paths that are traversed. I worry I may have issues with this approach on Windows but we'll see, if there is a better approach than this I'd like to know. |
No luck with GDB with Go files on Windows (segfaults on everything). It looks like there may be a problem with the creation of the file object itself and the names being passed in, if not here it is somewhere else further down the chain. Issue is still unresolved and this commit breaks recursive adding on other platforms, it's looking closer to target here so more testing required. The accidental extra line will be squashed in the next commit. Worth noting is that the same call is made in the unix adder as well. -Edit- |
@djdv in this case you may just Yes, there seems to be duplication of usage of From the latest hash, it appears that the fullpath has now been trimmed into name? The remaining problem is duplication of files being added? This is as if https://github.com/ipfs/go-ipfs/blob/master/commands/files/serialfile.go#L34 lists the entire content of a directory recursively. |
This commit is a squashed version of the previous commits with any experiments removed. While this commit fixes that issue as well, I am unsure as to why this behavior was happening to begin with or why this solves it. Outputting the paths and filenames at every stage during Since I cannot step through the code on this platform currently, I made the assumption that the filenames need to use forward slashes to be parsed correctly while the filepaths needed to use the platform specific delimiters for reading etc. but I couldn't actually confirm that this was the reason. Given the uncertainty I'll need someone who knows better than me to scrutinize the change as well as the ci. It builds and works on my machine as well as inside of a VM with the test directory and real data. After merging with the latest origin it builds and runs the same on FreeBSD as before the merge. The circleci failures seem to all be flagged with "# TODO known breakage". |
@whyrusleeping want to CR this one? |
@@ -69,7 +69,7 @@ func (f *serialFile) NextFile() (File, error) { | |||
f.files = f.files[1:] | |||
|
|||
// open the next file | |||
fileName := fp.Join(f.name, stat.Name()) | |||
fileName := fp.ToSlash(fp.Join(f.name, stat.Name())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of scope for this PR (probably) but I dont like this being fp
here and filepath
everywhere else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a likely cause of why forward slash is required here.
Because it is used in addNode
in core/commands/add.go
, which uses file.FileName()
as an argument to InsertNodeAtPath
.
https://github.com/ipfs/go-ipfs/blob/master/merkledag/utils/utils.go#L57 assumes a forward-slash-separated path.
LGTM |
@whyrusleeping @rht |
If the I initially thought standardizing toward forward slash is preferable (initial rationale: windows path appears only in
+1 for |
There are too many places in the code where hardcoded '/' is assumed, however. I think a sufficient fix just for |
@whyrusleeping @rht The attached image may better explain the |
Understood the Just to make sure:
Both fix the fullpath, '../', file duplication bugs, but not the |
Partially. When those fixes are applied we generate and get the correct hash but we also get an additional unrequested hash, the files and names inside the target hash are fine but not in the unwanted hash. In addition when To put that another way when those 2 things are applied we get The current PR commit will get the intended result in all cases (full, relative, ../relative, Sorry for the confusion, it's hard to explain when I don't know the root cause of it myself. There may be another method that solves this in other places that may or maynot be preferable. My proposal seems like a hacky fix at the end of the code path rather than a proper solution in the middle. |
Confirming, so at least '/'-standardizing the commands/cli/parse.go does fix all the naming issues. It would better to investigate the underlying cause so that the code can be further cleaned/clarified, but since the PR already works, LGTM. |
Agreed, it seems like the best course of action would be to implement this now so long as it appears fine to everyone and does not cause conflicts on other platforms/tests. This would be good for Windows users in the short term, in the future someone else or I can reassess this and look for the underlying issue if it doesn't get resolved naturally through refactoring other parts of the project. As for code cleanup I'll leave that alone since it's not introduced here and would be better as a separate broader request on its own. @jbenet |
Yes, rebase would be better in any situation regardless whether the osx-sharness will fail or not. ping @djdv |
@djdv currently all PRs are thwarted by the travis-osx failures. // not your fault |
Actually,
would do, too. |
I'm out of town at the moment and won't be able to run tests on OS X or Windows until I return, if someone else wants to beat me to it I'd appreciate it. |
osx sharness just passed https://travis-ci.org/ipfs/go-ipfs/builds/92901951 in #1975 |
@rht im reluctant to merge this until it passes every time. the problems -- we think -- are not coming from this PR, but we should not be merging more things while we have random failures on osx -- we should be fixing the random failures first-- then rebasing and proving these indeed do not introduce more random failures. Sorry @djdv -- we need to fix master first before i'd be comfortable merging this in. We could also use this time to setup a windows CI system -- @harlantwood any recs? |
appveyor: #1982 |
No idea on windows, sorry. I know @whyrusleeping dug into that a bit wrt Travis. |
@jbenet |
The windows test has plenty goroutine errs. It is not sensible at all to merge this after all those goroutine errs have been eliminated. #1933 (comment). I thought this is pretty clear? Travis doesn't have windows. The appveyor windows CI is added in #1982. To get this rolling (if want soon), it needs someone with go-ipfs admin access to enable the webhook. |
(...not sure of what kind of bureaucracy is going on here) |
License: MIT Signed-off-by: Dominic Della Valle <ddvpublic@gmail.com>
@jbenet |
@djdv we're all half on holiday at the moment (especially jbenet), we'll get to it right when we're back in january -- thanks for your patience! |
@lgierth |
The OSX failures here are unrelated, this has been waiting around for too long, merging. |
Fix path parser in add command
@whyrusleeping For the sake of completeness I just want to reference @rht's comment: #1933 (comment) |
Fix path parser in add command This commit was moved from ipfs/kubo@e007d1e
Parse paths with filepath instead of just path
#1922