question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
RyanZimcommented, 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?

0reactions
RyanZimcommented, May 4, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I move files in node.js? - Stack Overflow
According to seppo0010 comment, I used the rename function to do that. http://nodejs.org/docs/latest/api/fs.html#fs_fs_rename_oldpath_newpath_callback.
Read more >
Is there a way to make "mv" fail silently? - Unix Stack Exchange
You want to mute it only in case your glob expression doesn't return results. ... { move $file, $target or warn "Error moving...
Read more >
Moving files accidentally to an not existing directory erases files?
As Rinzwind says, moving files to a nonexistent destination directory shouldn't cause data loss when you attempt it using a single mv command....
Read more >
File.Move Method (System.IO) | Microsoft Learn
This method works across disk volumes, and it does not throw an exception if the source and destination are the same. Note that...
Read more >
node-fs-extra/move.md at master - GitHub
Using overwrite option​​ const fs = require('fs-extra') fs. move('/tmp/somedir', '/tmp/may/already/exist/somedir', { overwrite: true }, err => { if (err) return ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found