mirror of https://github.com/status-im/metro.git
Protect against races in deleting corrupt cache
Reviewed By: @cpojer Differential Revision: D2426450
This commit is contained in:
parent
68fb275c78
commit
c308774bc1
|
@ -20,7 +20,11 @@ function loadCacheSync(cachePath) {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof SyntaxError) {
|
if (e instanceof SyntaxError) {
|
||||||
console.warn('Unable to parse cache file. Will clear and continue.');
|
console.warn('Unable to parse cache file. Will clear and continue.');
|
||||||
|
try {
|
||||||
fs.unlinkSync(cachePath);
|
fs.unlinkSync(cachePath);
|
||||||
|
} catch (err) {
|
||||||
|
// Someone else might've deleted it.
|
||||||
|
}
|
||||||
return Object.create(null);
|
return Object.create(null);
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
|
|
Loading…
Reference in New Issue