Bug 1460095 Always flush the jar cache after looking at an xpi file
MozReview-Commit-ID: FHsbewyAnDm
--- a/toolkit/mozapps/extensions/internal/XPIInstall.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIInstall.jsm
@@ -341,26 +341,22 @@ DirPackage = class DirPackage extends Pa
}
};
XPIPackage = class XPIPackage extends Package {
constructor(file) {
super(file, getJarURI(file));
this.zipReader = new ZipReader(file);
- this.needFlush = false;
}
close() {
this.zipReader.close();
this.zipReader = null;
-
- if (this.needFlush) {
- this.flushCache();
- }
+ this.flushCache();
}
async hasResource(...path) {
return this.zipReader.hasEntry(path.join("/"));
}
async iterFiles(callback) {
for (let path of XPCOMUtils.IterStringEnumerator(this.zipReader.findEntries("*"))) {
@@ -369,17 +365,16 @@ XPIPackage = class XPIPackage extends Pa
path,
isDir: entry.isDirectory,
size: entry.realSize,
});
}
}
async readBinary(...path) {
- this.needFlush = true;
let response = await fetch(this.rootURI.resolve(path.join("/")));
return response.arrayBuffer();
}
verifySignedStateForRoot(addon, root) {
return new Promise(resolve => {
let callback = {
openSignedAppFileFinished(aRv, aZipReader, aCert) {
@@ -396,17 +391,16 @@ XPIPackage = class XPIPackage extends Pa
callback.wrappedJSObject = callback;
gCertDB.openSignedAppFileAsync(root, this.file, callback);
});
}
flushCache() {
flushJarCache(this.file);
- this.needFlush = false;
}
};
/**
* Determine the reason to pass to an extension's bootstrap methods when
* switch between versions.
*
* @param {string} oldVersion The version of the existing extension instance.