Skip to content

Commit

Permalink
fix(move-file): actually use the fallback to move-concurrently (#110)
Browse files Browse the repository at this point in the history
* Fix a typo, moveFile would always fail without link() available

* Add android to systems which can have a non-working link()

* remove special case here

this was a premature optimization. Let `move-concurrently` do its damn job on its own terms, here.
  • Loading branch information
Karol Baraniecki authored and zkat committed Nov 15, 2017
1 parent ae31cd6 commit 073fbe1
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions lib/util/move-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,18 @@ function moveFile (src, dest) {
}).then(() => {
// content should never change for any reason, so make it read-only
return BB.join(unlink(src), process.platform !== 'win32' && chmod(dest, '0444'))
}).catch(err => {
if (process.platform !== 'win32') {
throw err
} else {
if (!pinflight) { pinflight = require('promise-inflight') }
return pinflight('cacache-move-file:' + dest, () => {
return BB.promisify(fs.stat)(dest).catch(err => {
if (err !== 'ENOENT') {
// Something else is wrong here. Bail bail bail
throw err
}
// file doesn't already exist! let's try a rename -> copy fallback
if (!move) { move = require('move-concurrently') }
return move(src, dest, { BB, fs })
})
}).catch(() => {
if (!pinflight) { pinflight = require('promise-inflight') }
return pinflight('cacache-move-file:' + dest, () => {
return BB.promisify(fs.stat)(dest).catch(err => {
if (err.code !== 'ENOENT') {
// Something else is wrong here. Bail bail bail
throw err
}
// file doesn't already exist! let's try a rename -> copy fallback
if (!move) { move = require('move-concurrently') }
return move(src, dest, { BB, fs })
})
}
})
})
}

0 comments on commit 073fbe1

Please sign in to comment.