-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add ignore and hidden file support to add #1448
Conversation
|
||
fName := filepath.Base(f.FileName()) | ||
|
||
if strings.HasPrefix(fName, ".") && len(fName) > 1 { |
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.
this may capture ..
but not .
. is that intended? (maybe dont want it for either?)
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.
So I'm assuming that filepath.Base(f.FileName())
will wipe out any instance of the "double dot" because we're just looking at the last element of the Path. http://golang.org/pkg/path/filepath/#Base
According to the docs, we only get a file name or a "single dot" for an empty path, hence the len(fName) > 1
check.
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.
sounds good 👍
@gatesvp this LGTM! i'll give one more pass manually (playing with it) to see if there's any major UX flaws, and merge. thank you very much for all the work on this changeset. it will be very useful to tons of people! \o/ |
Hey @gatesvp am i doing something wrong?
|
hmmm... it's not matching the exact folder name? There's no test for the scenario of an ignore file that exactly matches a folder name. Let me add/run this test (after I sleep) and see if I can't figure out what we're missing? I suspect that |
it's not skipping ignored files. added but shouldn't have been: aa/b # should ignore "b" (parent)
b # should ignore "b"
bb/a # should ignore "a"
bb/b # should ignore "b" (parent) |
So I have my brain back and here's my test:
That should resemble your tree structure above. My output is
So it actually ignored the So it's all working as expected on Linux box. Is there a possible configuration issue here? |
in osx, with your branch, i get:
in linux, i get:
bizarre. wait, is there anything in need to do to the config? no, right? just build + install with |
Aha! Found the problem. Try it with the daemon on 😄 |
To be clear, without the daemon, i got the expected:
|
rootnd, err := addFile(n, file, outChan, progress, wrap, trickle) | ||
// If the file is not a folder, then let's get the root of that | ||
// folder and attempt to load the appropriate .ipfsignore. | ||
localIgnorePatterns := checkForParentIgnorePatterns(file.FileName(), ignoreFilePatterns) |
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.
the problem is that -- doing this here, in the Run
function, means it's getting executed in the daemon with the daemon chdir.
we need to do all this part (the ignores) before hand, in the PreRun (or in the cmdslib? maybe the cmdslib needs an option to be given a function like os.Walk
that decides whether to add files or not -- that way we can implement support for .ipfsignore
outside the cmdslib)
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.
the ignore logic should really go in commands/files
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.
the hidden logic should be fine to stay here though, we encode the files attributes and send them over. But the enumeration of which files to add is done in either commands/cli/parse
or commands/files
, namely the serialFile
struct (i think) which is basically a directory and when NextFile
is called on it, it will return the next item under it...
This change is more difficult than I first thought it would be...
👍 to moving all the misc parameters into a struct. Makes things a tad cleaner. |
@whyrusleeping we had the unfortunate discovery that this needs to change the cmdslib. do you think we should get rid of some of the |
this test fails .ipfsignore - only with daemon on. See: #1448 License: MIT Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
I split this PR into two parts:
|
@jbenet I think it may be worthwhile to use the |
@whyrusleeping i agree. |
#653 support, attempt number 4.
License: MIT
Signed-off-by: Gaetan Voyer-Perrault gatesvp@gmail.com