Skip to content
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

fs.move doesn't return error on moving same nonexistent folder/file #414

Closed
zosman1 opened this issue May 2, 2017 · 5 comments
Closed
Assignees

Comments

@zosman1
Copy link

zosman1 commented May 2, 2017

Issue:

When i fs.move() using two paths that are the same and both are invalid(nonexistent) paths, the function does not return an error, which it should since you are trying to move a nonexistent path.

Setup:

This is being ran inside of an electron render, which means its being ran inside of a chrome wrapper. This issue persists through fs-extra 3.0

Example:

fs.move("nonexistent/path","nonexistent/path", (err) => { console.log(err)})
// err returns null

Usage:

I use this in my personal repo:
https://github.com/zosman1/The_Archiver/blob/c65ed9dfb7ae0855b1fcb8026204c8d6876a96af/app/index.js#L25

@RyanZim
Copy link
Collaborator

RyanZim commented May 2, 2017

@zosman1 Confirmed this issue.

The reason this behaves this way is that fs-extra is designed to silently do nothing when the source and destination paths are the same. In that case, it doesn't even touch the filesystem, so no error is raised.

Right now, I'm questioning the wisdom of silently doing nothing when the source & dest is the same. I wonder if we should error out here? @jprichardson @manidlou thoughts?

@jprichardson
Copy link
Owner

How about this... if the source doesn't exist, return an error? That seems to me to almost certainly be unintentional.

@RyanZim
Copy link
Collaborator

RyanZim commented May 2, 2017

@jprichardson That's fine with me as a quick fix; but I wonder if we should really just be silently doing nothing when src and dest are the same in the long term.

I'll throw a patch together when I get a chance.

@manidlou
Copy link
Collaborator

manidlou commented May 2, 2017

I'll throw a patch together when I get a chance.

Thanks @RyanZim!

if the source doesn't exist, return an error? 👍

But what is wrong with informing user with an error when src and dest are the same?! We've already doing this for copy() though.

@RyanZim
Copy link
Collaborator

RyanZim commented May 2, 2017

Done: #378 #415

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants