mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-22 23:23:54 +08:00
fix(compile-cache): Write atomically to prevent process collisions
This commit is contained in:
parent
564d77421f
commit
a46bcd1c34
1 changed files with 3 additions and 1 deletions
|
@ -102,8 +102,10 @@ function readCachedJavascript (relativeCachePath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeCachedJavascript (relativeCachePath, code) {
|
function writeCachedJavascript (relativeCachePath, code) {
|
||||||
|
var cacheTmpPath = path.join(cacheDirectory, relativeCachePath + '.' + process.pid)
|
||||||
var cachePath = path.join(cacheDirectory, relativeCachePath)
|
var cachePath = path.join(cacheDirectory, relativeCachePath)
|
||||||
fs.writeFileSync(cachePath, code, 'utf8')
|
fs.writeFileSync(cacheTmpPath, code, 'utf8')
|
||||||
|
fs.renameSync(cacheTmpPath, cachePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function addSourceURL (jsCode, filePath) {
|
function addSourceURL (jsCode, filePath) {
|
||||||
|
|
Loading…
Reference in a new issue