Skip to content

Commit

Permalink
bugfix fs.move() moving directory across device. Closes #108
Browse files Browse the repository at this point in the history
  • Loading branch information
jprichardson committed Jan 28, 2015
1 parent c28fff8 commit fbcb042
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
0.16.0 / 2015-01-**
-------------------
- bugfix `fs.move()` into itself. Closes #104
- bugfix `fs.move()` moving directory across device. Closes #108

0.15.0 / 2015-01-21
-------------------
Expand Down
16 changes: 11 additions & 5 deletions lib/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,17 @@ function moveFileAcrossDevice(source, dest, clobber, limit, callback) {
outs.destroy()
outs.removeListener('close', onClose)

if (err.code === 'EISDIR' || err.code === 'EPERM') {
moveDirAcrossDevice(source, dest, clobber, limit, callback)
} else {
callback(err)
}
// may want to create a directory but `out` line above
// creates an empty file for us: See #108
// don't care about error here
fs.unlink(dest, function() {
// note: `err` here is from the input stream errror
if (err.code === 'EISDIR' || err.code === 'EPERM') {
moveDirAcrossDevice(source, dest, clobber, limit, callback)
} else {
callback(err)
}
})
})

outs.on('error', function(err) {
Expand Down

0 comments on commit fbcb042

Please sign in to comment.