Skip to content

Commit 073fbe1

Browse files
Karol Baranieckizkat
Karol Baraniecki
authored andcommittedNov 15, 2017
fix(move-file): actually use the fallback to move-concurrently (#110)
* 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.
1 parent ae31cd6 commit 073fbe1

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed
 

‎lib/util/move-file.js

+12-16
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,18 @@ function moveFile (src, dest) {
3434
}).then(() => {
3535
// content should never change for any reason, so make it read-only
3636
return BB.join(unlink(src), process.platform !== 'win32' && chmod(dest, '0444'))
37-
}).catch(err => {
38-
if (process.platform !== 'win32') {
39-
throw err
40-
} else {
41-
if (!pinflight) { pinflight = require('promise-inflight') }
42-
return pinflight('cacache-move-file:' + dest, () => {
43-
return BB.promisify(fs.stat)(dest).catch(err => {
44-
if (err !== 'ENOENT') {
45-
// Something else is wrong here. Bail bail bail
46-
throw err
47-
}
48-
// file doesn't already exist! let's try a rename -> copy fallback
49-
if (!move) { move = require('move-concurrently') }
50-
return move(src, dest, { BB, fs })
51-
})
37+
}).catch(() => {
38+
if (!pinflight) { pinflight = require('promise-inflight') }
39+
return pinflight('cacache-move-file:' + dest, () => {
40+
return BB.promisify(fs.stat)(dest).catch(err => {
41+
if (err.code !== 'ENOENT') {
42+
// Something else is wrong here. Bail bail bail
43+
throw err
44+
}
45+
// file doesn't already exist! let's try a rename -> copy fallback
46+
if (!move) { move = require('move-concurrently') }
47+
return move(src, dest, { BB, fs })
5248
})
53-
}
49+
})
5450
})
5551
}

0 commit comments

Comments
 (0)
Please sign in to comment.