-
Notifications
You must be signed in to change notification settings - Fork 772
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
Don't move when source and dest paths are the same. #378
Conversation
lib/move/index.js
Outdated
if (overwrite) { | ||
if (path.resolve(source) === path.resolve(dest)) { | ||
setTimeout(callback, 1) | ||
} else if (overwrite) { |
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.
fs.move
is async do you want it to exit early as such too (the setTimeout
).
Do y'all have a pattern in place for this already?
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.
@jdalton what are your thoughts on setTimeout
over setImmediate
? It's my understanding setTimeout
with an input of 1, still clamps to 15 ms.
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.
what are your thoughts on setTimeout over setImmediate? It's my understanding setTimeout with an input of 1, still clamps to 15 ms.
I have no strong opinions on it here since the primary goal is to just defer it a bit.
However, based on that goal setImmediate does look like a better call.
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.
Code LGTM, will approve when tests are added.
Before the behavior would error out, right? Should we consider this breaking? Thoughts @jdalton? |
It did error out. I would consider this a bug fix. (I haven't forgotten about the unit tests, just busy) |
What should be the correct behavior then? Since whatever that'd be, the same behavior should be applied to |
I'm asserting by the previous discussion, title, and behavior of this PR "Don't move when source and dest paths are the same." |
Added tests. |
Thank you @jdalton! |
This PR addresses #377 to avoid a move operation if the
source
anddest
paths are the same.(I'll add tests too, just wanted to get the ball rolling)