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

Fails to move (rename) directory to non-empty directory even with clobber: true #114

Closed
darobin opened this issue Feb 20, 2015 · 3 comments

Comments

@darobin
Copy link

darobin commented Feb 20, 2015

The docs seem to indicate that fs.move(dir, otherDir, { clobber: true }) will move a directory even if there is already content there. Looking at the code it seems that the intent is for that to work for files, it probably works for empty directories (that rename() is happy with) but it doesn't work for directories that have content. For that you need to fs.remove() them first. Maybe that's intentional (the tests don't exercise this case) but if so it should be documented as such.

@jprichardson
Copy link
Owner

Hmm. Good point. Do you think it makes sense to "move" a directory to a new directory that has content? It seems to me that should almost always produce an error. But since the functionality is provided for files, perhaps it should be possible for directories since the {clobber: true} makes the intent explicit.

What are your thoughts on the proper behavior?

@darobin
Copy link
Author

darobin commented Mar 3, 2015

There are cases when you just want to overwrite the directory. In my situation, I have cases in which I can just regenerate a subset of the content, and others in which being smart is hopeless and I just generate a fresh copy to replace the old with. In the latter case I need to build the fresh copy in a temp dir and replace the live one. I'd say if you've specified clobber, you should get clobber :)

@jprichardson
Copy link
Owner

Thanks for the report. Fixed and published!

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

No branches or pull requests

2 participants