зеркало из https://github.com/mozilla/gecko-dev.git
Bug 20043, attempting to install an older file should not abort rest of install
This commit is contained in:
Родитель
022b1a3ef9
Коммит
ef635f43af
|
@ -27,6 +27,7 @@
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
InstallFile=Installing: %s
|
InstallFile=Installing: %s
|
||||||
ReplaceFile=Replacing: %s
|
ReplaceFile=Replacing: %s
|
||||||
|
SkipFile=Skipping: %s
|
||||||
|
|
||||||
DeleteFile=Deleting file: %s
|
DeleteFile=Deleting file: %s
|
||||||
DeleteComponent=Deleting component: %s
|
DeleteComponent=Deleting component: %s
|
||||||
|
@ -42,7 +43,6 @@ Uninstall=Uninstalling: %s
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Dialog Messages
|
# Dialog Messages
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
ShouldWeInstallMsg=Attempting to download and install software. Do you feel lucky punk?
|
|
||||||
|
|
||||||
FinishingInstallMsg=Finishing install... please wait.
|
FinishingInstallMsg=Finishing install... please wait.
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
* Douglas Turner <dougt@netscape.com>
|
* Douglas Turner <dougt@netscape.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "prprf.h"
|
||||||
#include "nsInstallFile.h"
|
#include "nsInstallFile.h"
|
||||||
#include "nsFileSpec.h"
|
#include "nsFileSpec.h"
|
||||||
#include "VerReg.h"
|
#include "VerReg.h"
|
||||||
|
@ -51,28 +52,39 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
||||||
const nsString& inPartialPath,
|
const nsString& inPartialPath,
|
||||||
PRBool forceInstall,
|
PRBool forceInstall,
|
||||||
PRInt32 *error)
|
PRInt32 *error)
|
||||||
: nsInstallObject(inInstall)
|
: nsInstallObject(inInstall),
|
||||||
|
mVersionInfo(nsnull),
|
||||||
|
mJarLocation(nsnull),
|
||||||
|
mExtractedFile(nsnull),
|
||||||
|
mFinalFile(nsnull),
|
||||||
|
mVersionRegistryName(nsnull),
|
||||||
|
mForceInstall(forceInstall),
|
||||||
|
mReplaceFile(PR_FALSE),
|
||||||
|
mChildFile(PR_TRUE),
|
||||||
|
mUpgradeFile(PR_FALSE),
|
||||||
|
mSkipInstall(PR_FALSE)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsInstallFile);
|
MOZ_COUNT_CTOR(nsInstallFile);
|
||||||
|
|
||||||
mVersionRegistryName = nsnull;
|
|
||||||
mJarLocation = nsnull;
|
|
||||||
mExtracedFile = nsnull;
|
|
||||||
mFinalFile = nsnull;
|
|
||||||
mVersionInfo = nsnull;
|
|
||||||
|
|
||||||
mUpgradeFile = PR_FALSE;
|
|
||||||
|
|
||||||
if ((folderSpec == nsnull) || (inInstall == NULL))
|
if ((folderSpec == nsnull) || (inInstall == NULL))
|
||||||
{
|
{
|
||||||
*error = nsInstall::INVALID_ARGUMENTS;
|
*error = nsInstall::INVALID_ARGUMENTS;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*error = nsInstall::SUCCESS;
|
||||||
|
|
||||||
/* Check for existence of the newer version */
|
/* Check for existence of the newer version */
|
||||||
|
|
||||||
char* qualifiedRegNameString = inComponentName.ToNewCString();
|
char* qualifiedRegNameString = inComponentName.ToNewCString();
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
// we always install if forceInstall is true, or the new file's
|
||||||
|
// version is null, or the file doesn't previously exist.
|
||||||
|
//
|
||||||
|
// IFF it's not force, AND the new file has a version, AND it's been
|
||||||
|
// previously installed, THEN we have to do the version comparing foo.
|
||||||
|
// --------------------------------------------------------------------
|
||||||
if ( (forceInstall == PR_FALSE ) && (inVInfo != "") && ( VR_ValidateComponent( qualifiedRegNameString ) == 0 ) )
|
if ( (forceInstall == PR_FALSE ) && (inVInfo != "") && ( VR_ValidateComponent( qualifiedRegNameString ) == 0 ) )
|
||||||
{
|
{
|
||||||
nsInstallVersion *newVersion = new nsInstallVersion();
|
nsInstallVersion *newVersion = new nsInstallVersion();
|
||||||
|
@ -111,14 +123,12 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
||||||
delete oldVersion;
|
delete oldVersion;
|
||||||
delete newVersion;
|
delete newVersion;
|
||||||
|
|
||||||
if (areTheyEqual == nsIDOMInstallVersion::MAJOR_DIFF_MINUS ||
|
if ( areTheyEqual < 0 )
|
||||||
areTheyEqual == nsIDOMInstallVersion::MINOR_DIFF_MINUS ||
|
|
||||||
areTheyEqual == nsIDOMInstallVersion::REL_DIFF_MINUS ||
|
|
||||||
areTheyEqual == nsIDOMInstallVersion::BLD_DIFF_MINUS )
|
|
||||||
{
|
{
|
||||||
// the file to be installed is OLDER than what is on disk. Return error
|
// the file to be installed is OLDER than what is on disk.
|
||||||
|
// Don't install it.
|
||||||
Recycle(qualifiedRegNameString);
|
Recycle(qualifiedRegNameString);
|
||||||
*error = areTheyEqual;
|
mSkipInstall = PR_TRUE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,8 +182,6 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
||||||
nsFileSpec makeDirs(parent.GetCString(), PR_TRUE);
|
nsFileSpec makeDirs(parent.GetCString(), PR_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
mForceInstall = forceInstall;
|
|
||||||
|
|
||||||
mVersionRegistryName = new nsString(inComponentName);
|
mVersionRegistryName = new nsString(inComponentName);
|
||||||
mJarLocation = new nsString(inJarLocation);
|
mJarLocation = new nsString(inJarLocation);
|
||||||
mVersionInfo = new nsString(inVInfo);
|
mVersionInfo = new nsString(inVInfo);
|
||||||
|
@ -198,19 +206,9 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
mChildFile = mVersionRegistryName->Equals( regPackageName,
|
||||||
// there is no "starts with" api in nsString. LAME!
|
PR_FALSE,
|
||||||
nsString startsWith;
|
regPackageName.Length() );
|
||||||
mVersionRegistryName->Left(startsWith, regPackageName.Length());
|
|
||||||
|
|
||||||
if (startsWith.Equals(regPackageName))
|
|
||||||
{
|
|
||||||
mChildFile = PR_TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mChildFile = PR_FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,8 +221,8 @@ nsInstallFile::~nsInstallFile()
|
||||||
if (mJarLocation)
|
if (mJarLocation)
|
||||||
delete mJarLocation;
|
delete mJarLocation;
|
||||||
|
|
||||||
if (mExtracedFile)
|
if (mExtractedFile)
|
||||||
delete mExtracedFile;
|
delete mExtractedFile;
|
||||||
|
|
||||||
if (mFinalFile)
|
if (mFinalFile)
|
||||||
delete mFinalFile;
|
delete mFinalFile;
|
||||||
|
@ -240,10 +238,13 @@ nsInstallFile::~nsInstallFile()
|
||||||
*/
|
*/
|
||||||
PRInt32 nsInstallFile::Prepare()
|
PRInt32 nsInstallFile::Prepare()
|
||||||
{
|
{
|
||||||
if (mInstall == nsnull || mFinalFile == nsnull || mJarLocation == nsnull )
|
if (mInstall == nsnull || mFinalFile == nsnull || mJarLocation == nsnull )
|
||||||
return nsInstall::INVALID_ARGUMENTS;
|
return nsInstall::INVALID_ARGUMENTS;
|
||||||
|
|
||||||
return mInstall->ExtractFileFromJar(*mJarLocation, mFinalFile, &mExtracedFile);
|
if (mSkipInstall)
|
||||||
|
return nsInstall::SUCCESS;
|
||||||
|
|
||||||
|
return mInstall->ExtractFileFromJar(*mJarLocation, mFinalFile, &mExtractedFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Complete
|
/* Complete
|
||||||
|
@ -259,6 +260,9 @@ PRInt32 nsInstallFile::Complete()
|
||||||
{
|
{
|
||||||
return nsInstall::INVALID_ARGUMENTS;
|
return nsInstall::INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mSkipInstall)
|
||||||
|
return nsInstall::SUCCESS;
|
||||||
|
|
||||||
err = CompleteFileMove();
|
err = CompleteFileMove();
|
||||||
|
|
||||||
|
@ -273,48 +277,43 @@ PRInt32 nsInstallFile::Complete()
|
||||||
|
|
||||||
void nsInstallFile::Abort()
|
void nsInstallFile::Abort()
|
||||||
{
|
{
|
||||||
if (mExtracedFile != nsnull)
|
if (mExtractedFile != nsnull)
|
||||||
mExtracedFile->Delete(PR_FALSE);
|
mExtractedFile->Delete(PR_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define RESBUFSIZE 1024
|
||||||
char* nsInstallFile::toString()
|
char* nsInstallFile::toString()
|
||||||
{
|
{
|
||||||
char* buffer = new char[1024];
|
char* buffer = new char[RESBUFSIZE];
|
||||||
char* rsrcVal = "";
|
char* rsrcVal = nsnull;
|
||||||
|
const char* fname = nsnull;
|
||||||
|
|
||||||
if (buffer == nsnull || !mInstall)
|
if (buffer == nsnull || !mInstall)
|
||||||
return nsnull;
|
return nsnull;
|
||||||
|
else
|
||||||
|
buffer[0] = '\0';
|
||||||
|
|
||||||
if (mFinalFile == nsnull)
|
if (mReplaceFile)
|
||||||
{
|
{
|
||||||
rsrcVal = mInstall->GetResourcedString("InstallFile");
|
|
||||||
|
|
||||||
if (rsrcVal)
|
|
||||||
{
|
|
||||||
sprintf( buffer, rsrcVal, nsnull);
|
|
||||||
nsCRT::free(rsrcVal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (mReplaceFile)
|
|
||||||
{
|
|
||||||
// we are replacing this file.
|
|
||||||
rsrcVal = mInstall->GetResourcedString("ReplaceFile");
|
rsrcVal = mInstall->GetResourcedString("ReplaceFile");
|
||||||
|
}
|
||||||
if (rsrcVal)
|
else if (mSkipInstall)
|
||||||
{
|
{
|
||||||
sprintf( buffer, rsrcVal, mFinalFile->GetCString());
|
rsrcVal = mInstall->GetResourcedString("SkipFile");
|
||||||
nsCRT::free(rsrcVal);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rsrcVal = mInstall->GetResourcedString("InstallFile");
|
rsrcVal = mInstall->GetResourcedString("InstallFile");
|
||||||
|
}
|
||||||
|
|
||||||
if (rsrcVal)
|
if (rsrcVal)
|
||||||
{
|
{
|
||||||
sprintf( buffer, rsrcVal, mFinalFile->GetCString());
|
if (mFinalFile)
|
||||||
nsCRT::free(rsrcVal);
|
fname = mFinalFile->GetCString();
|
||||||
}
|
|
||||||
|
PR_snprintf( buffer, RESBUFSIZE, rsrcVal, fname );
|
||||||
|
|
||||||
|
Recycle(rsrcVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
|
@ -325,19 +324,19 @@ PRInt32 nsInstallFile::CompleteFileMove()
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
if (mExtracedFile == nsnull)
|
if (mExtractedFile == nsnull)
|
||||||
{
|
{
|
||||||
return -1;
|
return nsInstall::UNEXPECTED_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( *mExtracedFile == *mFinalFile )
|
if ( *mExtractedFile == *mFinalFile )
|
||||||
{
|
{
|
||||||
/* No need to rename, they are the same */
|
/* No need to rename, they are the same */
|
||||||
result = 0;
|
result = nsInstall::SUCCESS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = ReplaceFileNowOrSchedule(*mExtracedFile, *mFinalFile );
|
result = ReplaceFileNowOrSchedule(*mExtractedFile, *mFinalFile );
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -67,23 +67,24 @@ class nsInstallFile : public nsInstallObject
|
||||||
|
|
||||||
PRBool CanUninstall();
|
PRBool CanUninstall();
|
||||||
PRBool RegisterPackageNode();
|
PRBool RegisterPackageNode();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/* Private Fields */
|
/* Private Fields */
|
||||||
nsString* mVersionInfo; /* Version info for this file*/
|
nsString* mVersionInfo; /* Version info for this file*/
|
||||||
|
|
||||||
nsString* mJarLocation; /* Location in the JAR */
|
nsString* mJarLocation; /* Location in the JAR */
|
||||||
nsFileSpec* mExtracedFile; /* temporary file location */
|
nsFileSpec* mExtractedFile; /* temporary file location */
|
||||||
nsFileSpec* mFinalFile; /* final file destination */
|
nsFileSpec* mFinalFile; /* final file destination */
|
||||||
|
|
||||||
nsString* mVersionRegistryName; /* full version path */
|
nsString* mVersionRegistryName; /* full version path */
|
||||||
|
|
||||||
PRBool mForceInstall; /* whether install is forced */
|
PRBool mForceInstall; /* whether install is forced */
|
||||||
PRBool mReplaceFile; /* whether file exists */
|
PRBool mReplaceFile; /* whether file exists */
|
||||||
PRBool mChildFile; /* whether file is a child */
|
PRBool mChildFile; /* whether file is a child */
|
||||||
PRBool mUpgradeFile; /* whether file is an upgrade */
|
PRBool mUpgradeFile; /* whether file is an upgrade */
|
||||||
|
PRBool mSkipInstall; /* if true don't install this file */
|
||||||
|
|
||||||
|
|
||||||
PRInt32 CompleteFileMove();
|
PRInt32 CompleteFileMove();
|
||||||
|
|
|
@ -35,6 +35,7 @@ static nsXPIResourceTableItem XPIResTable[] =
|
||||||
*---------------------------------------------------------------------*/
|
*---------------------------------------------------------------------*/
|
||||||
{ "InstallFile", "Installing: %s" },
|
{ "InstallFile", "Installing: %s" },
|
||||||
{ "ReplaceFile", "Replacing: %s" },
|
{ "ReplaceFile", "Replacing: %s" },
|
||||||
|
{ "SkipFile", "Skipping: %s" },
|
||||||
{ "DeleteFile", "Deleting file: %s" },
|
{ "DeleteFile", "Deleting file: %s" },
|
||||||
{ "DeleteComponent", "Deleting component: %s" },
|
{ "DeleteComponent", "Deleting component: %s" },
|
||||||
{ "Execute", "Executing: %s" },
|
{ "Execute", "Executing: %s" },
|
||||||
|
@ -48,7 +49,6 @@ static nsXPIResourceTableItem XPIResTable[] =
|
||||||
/*---------------------------------------------------------------------*
|
/*---------------------------------------------------------------------*
|
||||||
* Dialog Messages
|
* Dialog Messages
|
||||||
*---------------------------------------------------------------------*/
|
*---------------------------------------------------------------------*/
|
||||||
{ "ShouldWeInstallMsg", "Attempting to download and install software. Do you feel lucky punk?" },
|
|
||||||
{ "FinishingInstallMsg", "Finishing install... please wait." },
|
{ "FinishingInstallMsg", "Finishing install... please wait." },
|
||||||
|
|
||||||
/*---------------------------------------------------------------------*
|
/*---------------------------------------------------------------------*
|
||||||
|
|
|
@ -69,9 +69,9 @@ nsLoggingProgressNotifier::BeforeJavascriptEvaluation(const PRUnichar *URL)
|
||||||
|
|
||||||
mLogStream->seek(logFile.GetFileSize());
|
mLogStream->seek(logFile.GetFileSize());
|
||||||
|
|
||||||
*mLogStream << "---------------------------------------------------------------------------" << nsEndl;
|
*mLogStream << "-------------------------------------------------------------------------------" << nsEndl;
|
||||||
*mLogStream << nsAutoCString(URL) << " -- " << time << nsEndl;
|
*mLogStream << nsAutoCString(URL) << " -- " << time << nsEndl;
|
||||||
*mLogStream << "---------------------------------------------------------------------------" << nsEndl;
|
*mLogStream << "-------------------------------------------------------------------------------" << nsEndl;
|
||||||
*mLogStream << nsEndl;
|
*mLogStream << nsEndl;
|
||||||
|
|
||||||
PL_strfree(time);
|
PL_strfree(time);
|
||||||
|
@ -135,7 +135,7 @@ nsLoggingProgressNotifier::FinalizeProgress(const PRUnichar* message, PRInt32 it
|
||||||
{
|
{
|
||||||
if (mLogStream == nsnull) return NS_ERROR_NULL_POINTER;
|
if (mLogStream == nsnull) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
*mLogStream << " Item [" << (itemNum) << "/" << totNum << "]\t" << nsAutoCString(message) << nsEndl;
|
*mLogStream << " [" << (itemNum) << "/" << totNum << "]\t" << nsAutoCString(message) << nsEndl;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче