Skip to content

Commit cfaec14

Browse files
committed
Fix tmp files mv across physical devics
1 parent f4ab221 commit cfaec14

File tree

3 files changed

+48
-16
lines changed

3 files changed

+48
-16
lines changed

lib/cache.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ var path = require('path'),
33
fs = require('fs'),
44
os = require('os'),
55
crypto = require('crypto'),
6-
mkdirp = require('mkdirp');
6+
mkdirp = require('mkdirp'),
7+
mv = require('mv');
78

89
function Cache(opts) {
910
this.opts = opts || {};
@@ -85,9 +86,10 @@ function Cache(opts) {
8586

8687
// Release the lock, move data file to final destination.
8788
delete (locks[key]);
88-
fs.renameSync(tmpPath, pathInfo.full);
89-
90-
self.meta(key, cb);
89+
mv(tmpPath, pathInfo.full, function(err) {
90+
if (err) { return cb(err); }
91+
self.meta(key, cb);
92+
});
9193
});
9294
};
9395

package-lock.json

Lines changed: 41 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"commander": "^2.15.1",
99
"log4js": "^0.6.26",
1010
"mkdirp": "^0.5.1",
11+
"mv": "^2.1.1",
1112
"request": "^2.81.0"
1213
},
1314
"description": "HTTP/HTTPS caching proxy for work with `npm` utility / registry",

0 commit comments

Comments
 (0)