mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 12:45:37 +08:00
Protect against races in deleting corrupt cache
Reviewed By: @cpojer Differential Revision: D2426450
This commit is contained in:
committed by
facebook-github-bot-6
parent
cd4e8a9fae
commit
3ee65225be
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user