mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1265621 - Add flag to track omnijar handle in nsJAR; r=aklotz
Add a bool flag in nsJAR to track whether the zip handle came from omnijar. The old code compared pointers instead, but other patches in this bug made it no longer possible to do that.
This commit is contained in:
parent
93b208fc7e
commit
4932a777ef
@ -86,7 +86,8 @@ nsJAR::nsJAR(): mZip(new nsZipArchive()),
|
||||
mLock("nsJAR::mLock"),
|
||||
mMtime(0),
|
||||
mTotalItemsInManifest(0),
|
||||
mOpened(false)
|
||||
mOpened(false),
|
||||
mIsOmnijar(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -141,6 +142,7 @@ nsJAR::Open(nsIFile* zipFile)
|
||||
RefPtr<nsZipArchive> zip = mozilla::Omnijar::GetReader(zipFile);
|
||||
if (zip) {
|
||||
mZip = zip;
|
||||
mIsOmnijar = true;
|
||||
return NS_OK;
|
||||
}
|
||||
return mZip->OpenArchive(zipFile);
|
||||
@ -201,19 +203,23 @@ nsJAR::GetFile(nsIFile* *result)
|
||||
NS_IMETHODIMP
|
||||
nsJAR::Close()
|
||||
{
|
||||
if (!mOpened) {
|
||||
return NS_ERROR_FAILURE; // Never opened or already closed.
|
||||
}
|
||||
|
||||
mOpened = false;
|
||||
mParsedManifest = false;
|
||||
mManifestData.Clear();
|
||||
mGlobalStatus = JAR_MANIFEST_NOT_PARSED;
|
||||
mTotalItemsInManifest = 0;
|
||||
|
||||
RefPtr<nsZipArchive> greOmni = mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE);
|
||||
RefPtr<nsZipArchive> appOmni = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP);
|
||||
|
||||
if (mZip == greOmni || mZip == appOmni) {
|
||||
if (mIsOmnijar) {
|
||||
// Reset state, but don't close the omnijar because we did not open it.
|
||||
mIsOmnijar = false;
|
||||
mZip = new nsZipArchive();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return mZip->CloseArchive();
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,7 @@ class nsJAR final : public nsIZipReader
|
||||
int64_t mMtime;
|
||||
int32_t mTotalItemsInManifest;
|
||||
bool mOpened;
|
||||
bool mIsOmnijar;
|
||||
|
||||
nsresult ParseManifest();
|
||||
void ReportError(const nsACString &aFilename, int16_t errorCode);
|
||||
|
Loading…
Reference in New Issue
Block a user