Skip to content

Commit

Permalink
Use move-file instead of move-file-concurrently
Browse files Browse the repository at this point in the history
Cacache only ever moves individual files, and move-file-concurrently
does a lot more than that, and has a lot of very outdated deps.

move-file does the same basic thing, but for a single file only, and
without the additional deps that are better to remove.

It does mean that, since copyFile is not an atomic operation, we can
end up files getting corrupted in some extremely unlikely situations,
but that will just be treated as a cache miss by most users anyhow.

Fix #33
  • Loading branch information
isaacs committed Apr 28, 2020
1 parent f9c677b commit 92b1251
Show file tree
Hide file tree
Showing 4 changed files with 1,512 additions and 1,358 deletions.
5 changes: 3 additions & 2 deletions lib/util/move-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const util = require('util')
const chmod = util.promisify(fs.chmod)
const unlink = util.promisify(fs.unlink)
const stat = util.promisify(fs.stat)
const move = require('move-concurrently')
const move = require('move-file')
const pinflight = require('promise-inflight')

module.exports = moveFile
Expand Down Expand Up @@ -61,7 +61,8 @@ function moveFile (src, dest) {
throw err
}
// file doesn't already exist! let's try a rename -> copy fallback
return move(src, dest, { Promise, fs })
// only delete if it successfully copies
return move(src, dest)
})
})
})
Expand Down
Loading

0 comments on commit 92b1251

Please sign in to comment.