Protect against races in deleting corrupt cache

Reviewed By: @cpojer

Differential Revision: D2426450
This commit is contained in:
Amjad Masad
2015-09-09 15:59:35 -07:00
committed by facebook-github-bot-6
parent cd4e8a9fae
commit 3ee65225be

View File

@@ -20,7 +20,11 @@ function loadCacheSync(cachePath) {
} catch (e) {
if (e instanceof SyntaxError) {
console.warn('Unable to parse cache file. Will clear and continue.');
fs.unlinkSync(cachePath);
try {
fs.unlinkSync(cachePath);
} catch (err) {
// Someone else might've deleted it.
}
return Object.create(null);
}
throw e;