Closed
Description
fse.copy('src','src/dest')
will create the dest continues to recurse, and finally it throws an error ENAMETOOLONG
It links to AvianFlu/ncp#4
Metadata
Metadata
Assignees
Projects
Relationships
Development
No branches or pull requests
Activity
danyshaanan commentedon Sep 9, 2014
How does
require('fs').copy
handle this case?jprichardson commentedon Jul 13, 2015
Off the cuff, I'd say that I could just resolve the paths and check if one is a substring of the other. But I'd be concerned about introducing regressions. Thoughts?
iwege commentedon Jul 14, 2015
I have collected some cases in this pr AvianFlu/ncp#61, maybe you can use it as a reference.
jprichardson commentedon Oct 28, 2015
@lwege are you still interested in this getting fixed? I'd like to tackle this - it'd be awesome to take your list of cases and turn them into tests for both *nix and Windows.
iwege commentedon Nov 15, 2015
@jimhigson I copied testcase to https://github.com/iwege/node-fs-extra/tree/feature/prevent-copy-to-self , but how can I test it first? Or do I need to fix this issue with my old code?
jprichardson commentedon Nov 15, 2015
Would you link directly to the test case so that I can take a look? Thanks.
iwege commentedon Nov 15, 2015
@jprichardson iwege@0dc1610
jprichardson commentedon Dec 17, 2015
Thank you. Tests look good. Any thoughts on a reliable fix?
iwege commentedon Dec 24, 2015
I have used the AvianFlu/ncp#61 in my project and no one reports relative issue to me. But I don't know it reliable or not. Maybe my user doesn't do this in my product.
DaneEveritt commentedon Oct 3, 2016
Sorry to bring this back up, but any progress on implementing this, or should I add my own checks?
jprichardson commentedon Oct 3, 2016
What checks would you add?
DaneEveritt commentedon Oct 3, 2016
I built off @iwege's changes, and made the following function that I'm using before I call the move function.
Prevents moving folders into themselves, but doesn't block moving a folder into another folder that starts with the same name (so
src
can still move intosrc-dest
, but not intosrc
).Renaming files to the same name also triggers the catch, but that doesn't bother me so much.
43 remaining items