Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork435
Use a local Walk function#421
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Because arduino-cli segfaults when sketchDir is a symbolic link, a simplewalk function is introduced with a twofold effect:- fix the segfault- allow to use symlinksref:https://www.google.com/search?q=golang+Walk+does+not+follow+symbolic+links
CLAassistant commentedSep 22, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
cmaglie commentedOct 8, 2019
Hi@d-a-v, thank for your submission. We already have an implementation of the "walk-folllowing-symlinks" here: BTW, I was wondering why the golang This seems to be not golang-related but also other language that allows following symlinks suffer the same problem, for example in python we have: https://docs.python.org/3/library/os.html#os.walk that warns:
Since it seems that there isn't a saner/simple way to avoid loop we want to propose the following solution:
this should cover the use cases in#424 (and I think 99.99% of the overall use cases). |
d-a-v commentedOct 9, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thanks, I'm happy to close this PR when#424 is fixed by another mean. (edited) About the walking issue with symbolic links, we can add a decreasing counter in the recursive walk function (like the factorial recursive function we learn at school), and return an error (like I've also read the golang issues in their repository and I just don't understand why or how they would rewrite (or avoid) the unix features their own way. A symbolic link loop is on user responsibility Golang sys lib's responsibility is only to not fail (heap here), not to remove any OS functionality IMHO. |
rsora commentedOct 15, 2019
Hi@d-a-v , We want to use your PR as a starting point to introduce a more robust As a second step, we will make the Thanks for your help! |
d-a-v commentedOct 15, 2019
I'd be glad to. First I need to know whether you agree with the idea that a path depth shall not be more than a given constant (like 40, similar to what's done inlinux kernel Shall I make this proposal overthis file (instead of mine) ? Is it intended to stay where it is ? |
masci commentedOct 15, 2019
My 2c:
|
rsora commentedOct 15, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
- act on error in walk function (OS can detect symbolic links loops (lnk -> lnk))- add a deepness detector for non trivial loops (dir/lnk -> ../..)
d-a-v commentedOct 23, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Testing the error was missing in the user walk function, A reference to this issue is added in a comment about the discussion on |
d-a-v commentedOct 24, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
How to test this code (with linux): (OS error printed) Or not detectable by OS: (depth detection error) |
cmaglie commentedOct 24, 2019
Maybe we should differentiate two cases here:
Here the tricky case (2): it seems that |
d-a-v commentedOct 24, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
These two cases are handled by this PR. About |
arduino/builder/sketch.go Outdated
| } | ||
| // SimpleLocalWalk locally replaces filepath.Walk and/but goes through symlinks | ||
| funcSimpleLocalWalk(rootstring,walkFnfunc(pathstring,info os.FileInfo,errerror)error)error { |
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.
ThesimpleLocalWalkRecursive() is currently used in this module only, There's no need to wrap it and export it. Can you please remove the wrapper and use directlysimpleLocalWalkRecursive()?
Regarding themaxDepth param, can you please create a private constant in this module (named for example maxFileSystemDepth) documenting it properly writing something like:As currently implemented on Linux, the maximum number of symbolic links that will be followed while resolving a pathname is 40? This way you can use something more meaningful as a parameter when calling the function.
Thanks!
rsora commentedOct 28, 2019
Hi@d-a-v! I left a comment on your code. |
arduino/builder/sketch.go Outdated
| err=SimpleLocalWalk(sketchFolder,func(pathstring,info os.FileInfo,errerror)error { | ||
| iferr!=nil { | ||
| fmt.Printf("\nerror: %+v\n\n",err) |
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.
you can use the/cli/feedback package to print error messages like
feedback.Errorf("Error ....: %v", err)d-a-v commentedOct 28, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@rsora I think I addressed your review. |
masci commentedOct 29, 2019
@d-a-v can you try manually running |
d-a-v commentedOct 29, 2019
@masci I don't understand CI messages though. |
d-a-v commentedOct 29, 2019
What about a script to run before pushing changes that would run CI tests locally ? |
masci commentedOct 29, 2019
@d-a-v our contributing guidelines already explain how to run tests locally before pushing code:https://github.com/arduino/arduino-cli/blob/master/CONTRIBUTING.md#running-the-tests The style check, |
Uh oh!
There was an error while loading.Please reload this page.
rsora commentedOct 29, 2019
Hi@d-a-v , left a comment regarding the error management. |
Co-Authored-By: Roberto Sora <r.sora@arduino.cc>
d-a-v commentedOct 29, 2019
fixes addressed, CI passed, thanks for your feedback. |
rsora left a comment
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.
Excellent! 👍
Uh oh!
There was an error while loading.Please reload this page.
Because arduino-cli segfaults when sketchDir is a symbolic link,
a simple walk function is introduced with a twofold effect:
ref:https://www.google.com/search?q=golang+Walk+does+not+follow+symbolic+links
edit: