Compare commits

...

2 Commits

Author SHA1 Message Date
Alex Kocharin
ab157ad453 0.13.1 2014-11-01 23:11:54 +03:00
Alex Kocharin
494dc0feeb add a workaround for EPERM issue on windows 2014-11-01 23:05:26 +03:00
3 changed files with 30 additions and 2 deletions

View File

@@ -1,4 +1,8 @@
1 Nov 2014, version 0.13.1
- fix `EPERM`-related crashes on windows (issue [#67])
22 Oct 2014, version 0.13.0
- web interface:

View File

@@ -25,7 +25,31 @@ function write(dest, data, cb) {
var tmpname = dest + '.tmp' + String(Math.random()).substr(2)
fs.writeFile(tmpname, data, function(err) {
if (err) return cb(err)
return fs.rename(tmpname, dest, cb)
fs.rename(tmpname, dest, function(err) {
if (err) fs.unlink(tmpname)
if (err && err.code === 'EPERM' && process.platform.match(/^win/)) {
// windows isn't seem to be compatible with our locking
// algorithm, here is a simplified issue:
//
// fd = fs.openSync('file')
// fs.writeFileSync('file.tmp', 'blah')
// fs.renameSync('file.tmp', 'file')
// fs.closeSync(fd)
//
// fs.writeFileSync seem to work fine here, as long as
// you don't run multiple instances on windows
//
// fs.writeFile might still be prone to race conditions
// (not sure)
err = null
try {
fs.writeFileSync(dest, data)
} catch(_err) {
err = _err
}
}
cb(err)
})
})
}

View File

@@ -1,7 +1,7 @@
# use "yapm install ." if you're installing this from git repository
name: sinopia
version: 0.13.0
version: 0.13.1
description: Private npm repository server
author: