mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-05 20:04:10 +01:00
Gracefully handle more instances of corrupted cache files.
This commit is contained in:
@@ -36,7 +36,13 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
|
|||||||
return [contentType, cache.force(path)];
|
return [contentType, cache.force(path)];
|
||||||
|
|
||||||
let channel = services.StreamChannel(uri);
|
let channel = services.StreamChannel(uri);
|
||||||
channel.contentStream = cache.cacheReader.getInputStream(path);
|
try {
|
||||||
|
channel.contentStream = cache.cacheReader.getInputStream(path);
|
||||||
|
}
|
||||||
|
catch (e if e.result = Cr.NS_ERROR_FILE_CORRUPTED) {
|
||||||
|
cache.flushDiskCache();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
channel.contentType = contentType;
|
channel.contentType = contentType;
|
||||||
channel.contentCharset = "UTF-8";
|
channel.contentCharset = "UTF-8";
|
||||||
return channel;
|
return channel;
|
||||||
@@ -83,8 +89,7 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
|
|||||||
}
|
}
|
||||||
catch (e if e.result == Cr.NS_ERROR_FILE_CORRUPTED) {
|
catch (e if e.result == Cr.NS_ERROR_FILE_CORRUPTED) {
|
||||||
util.reportError(e);
|
util.reportError(e);
|
||||||
this.closeWriter();
|
this.flushDiskCache();
|
||||||
this.cacheFile.remove(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._cacheReader;
|
return this._cacheReader;
|
||||||
@@ -133,8 +138,12 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
|
|||||||
|
|
||||||
flush: function flush() {
|
flush: function flush() {
|
||||||
cache.cache = {};
|
cache.cache = {};
|
||||||
|
this.flushDiskCache();
|
||||||
|
},
|
||||||
|
|
||||||
|
flushDiskCache: function flushDiskCache() {
|
||||||
if (this.cacheFile.exists()) {
|
if (this.cacheFile.exists()) {
|
||||||
this.closeReader();
|
this.closeWriter();
|
||||||
|
|
||||||
this.flushJAR(this.cacheFile);
|
this.flushJAR(this.cacheFile);
|
||||||
this.cacheFile.remove(false);
|
this.cacheFile.remove(false);
|
||||||
@@ -170,8 +179,13 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
|
|||||||
util.waitFor(() => !this.inQueue);
|
util.waitFor(() => !this.inQueue);
|
||||||
|
|
||||||
if (this.cacheReader && this.cacheReader.hasEntry(name)) {
|
if (this.cacheReader && this.cacheReader.hasEntry(name)) {
|
||||||
return this.parse(File.readStream(
|
try {
|
||||||
this.cacheReader.getInputStream(name)));
|
return this.parse(File.readStream(
|
||||||
|
this.cacheReader.getInputStream(name)));
|
||||||
|
}
|
||||||
|
catch (e if e.result == Cr.NS_ERROR_FILE_CORRUPTED) {
|
||||||
|
this.flushDiskCache();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasOwnProperty(this.localProviders, name) && !this.isLocal) {
|
if (hasOwnProperty(this.localProviders, name) && !this.isLocal) {
|
||||||
|
|||||||
Reference in New Issue
Block a user