-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Change the behavior of file.recurse so that it will log an error if it p... #1170
base: main
Are you sure you want to change the base?
Conversation
…t processes a broken symlink instead of causing a fatal error. We wrap the call to fs.statSync(filepath).isDirectory() in a try/catch block, then log on the error condition.
package.json
Outdated
@@ -1,7 +1,7 @@ | |||
{ | |||
"name": "grunt", | |||
"description": "The JavaScript Task Runner", | |||
"version": "0.4.6-0", | |||
"version": "0.4.6-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.
don't bump the version
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.
Noted, reverted the version bump.
Reverting version bump
} catch (e) { | ||
grunt.log.error(e); | ||
} | ||
if (isDirectory) { | ||
recurse(rootdir, callback, unixifyPath(path.join(subdir || '', filename || ''))); | ||
} else { | ||
callback(unixifyPath(filepath), rootdir, subdir, filename); |
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.
callback would still fire if there is an 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.
As this is, yeah. I am not sure what would be best to do in the situation. Current behavior is a fatal error and a hard stop if it encounters a broken symlink. With this change, it will log an error and continue on. Unfortunately, fs.statSync(filepath) just throws a generic error, so we can't get more specific with the catch clause.
Right now, this is what happens for each file:
Should this be the desired behavior?
Will this cause problems for anyone? |
Getting rid of this new line. Emacs keeps adding them.
ping @iancreditkarma ^ |
Ah sorry. I was waiting for additional comment from others. The description @cowboy gave is almost correct. The only difference is that the file would not be skipped if it failed the stat. It would be passed to the callback and an error level log would be produced. I was thinking about this more and this should probably function more or less like the bare invocation of the unix utility It should probably be up to the callback to handle any issues that arise with the files passed during the directory recursion. |
@iancreditkarma what benefit is there if the callback is called for a file that can't be statted? It seems like it should be skipped. |
ping @iancreditkarma ^ |
@cowboy @vladikoff - That sounds pretty reasonable - skipping files that can't be statted. I'm out of town until tomorrow. I'll update the pull request as soon as I get back in town. |
Ping @iancreditkarma any updates? |
...rocesses a broken symlink instead of causing a fatal error. We wrap the call to fs.statSync(filepath).isDirectory() in a try/catch block, then log on the error condition.
This changes relates to this issue I filled - #1165