Closed RyanZim closed 1 year ago
@manidlou @bcoe bump
I have been trying to write a test case for this; I cannot get to a place where this condition is ever reached. Do we need this at all? Or what am I missing?
@RyanZim thank you for your efforts! I really appreciate it!
This is basically a wild edge case where we're trying to avoid broken copy when src is a link and its resolved path is inside the dest directory. We already have this test
so, what's wrong with this test?
@manidlou The problem is that that test doesn't actually exercise this condition. We'd expect the error to be of the format:
Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.
Instead, if you insert a log statement in that test, the actual error thrown is:
Error: Cannot overwrite directory '/tmp/fs-extra/copy-prevent-copying-into-itself/dest' with non-directory '/tmp/fs-extra/copy-prevent-copying-into-itself/src-symlink'.
I'm going to merge this as-is, without an explicit test, as it's certainly better than what we have now. However, we should still look into properly testing this later.
Thank you @RyanZim! That makes sense.
As per https://github.com/nodejs/node/pull/39372#discussion_r1001179295; haven't gotten a response from @bcoe there yet
Resolves https://github.com/jprichardson/node-fs-extra/issues/918
Hope this logic is right.