Bug 238741 ExistAllXPIs should check that the .xpi files are actually ok

patch by ajschult, r=benjamin sr=dveditz a=asa
This commit is contained in:
cst%andrew.cmu.edu 2005-07-14 01:44:15 +00:00
parent 0e3f234179
commit 8689c6c484
3 changed files with 48 additions and 65 deletions

View File

@ -129,8 +129,6 @@ void
nsInstallDlg::Next(GtkWidget *aWidget, gpointer aData)
{
DUMP("Next");
int bCus;
nsComponentList *comps = NULL;
GtkWidget *pauseLabel, *resumeLabel;
if (aData != gCtx->idlg) return;
@ -143,16 +141,7 @@ nsInstallDlg::Next(GtkWidget *aWidget, gpointer aData)
}
#endif
bCus = (gCtx->opt->mSetupType == (gCtx->sdlg->GetNumSetupTypes() - 1));
comps = gCtx->sdlg->GetSelectedSetupType()->GetComponents();
// initialize progress bar cleanly
int totalComps = 0;
if (nsXIEngine::ExistAllXPIs(bCus, comps, &totalComps))
bDownload = FALSE;
else
bDownload = TRUE;
if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT) {
gtk_progress_set_activity_mode(GTK_PROGRESS(sMajorProgBar), FALSE);
gtk_progress_bar_update(GTK_PROGRESS_BAR(sMajorProgBar), (gfloat) 0);
@ -392,10 +381,11 @@ int
nsInstallDlg::Show()
{
int err = OK;
int totalComps = 0;
GtkWidget *hbox = NULL;
GtkWidget *vbox = NULL;
GtkWidget *dlFrame, *dlCheckbox, *dlProxyBtn;
int bCus;
nsComponentList *comps = NULL;
XI_VERIFY(gCtx);
XI_VERIFY(gCtx->notebook);
@ -495,16 +485,18 @@ nsInstallDlg::Show()
gtk_widget_show(mTable);
}
int bCus =
(gCtx->opt->mSetupType == (gCtx->sdlg->GetNumSetupTypes() - 1));
nsComponentList *comps =
gCtx->sdlg->GetSelectedSetupType()->GetComponents();
bCus = (gCtx->opt->mSetupType == (gCtx->sdlg->GetNumSetupTypes() - 1));
comps = gCtx->sdlg->GetSelectedSetupType()->GetComponents();
if (!nsXIEngine::ExistAllXPIs(bCus, comps, &totalComps))
if (!nsXIEngine::ExistAllXPIs(bCus, comps))
{
bDownload = TRUE;
gtk_widget_show(sDLTable);
}
else
{
bDownload = FALSE;
}
// signal connect the buttons
gCtx->backID = gtk_signal_connect(GTK_OBJECT(gCtx->back), "clicked",
@ -625,40 +617,38 @@ nsInstallDlg::PerformInstall()
nsComponentList *comps = NULL;
nsComponent *xpiengine = NULL;
int bCus = (gCtx->opt->mSetupType == (gCtx->sdlg->GetNumSetupTypes() - 1));
comps = gCtx->sdlg->GetSelectedSetupType()->GetComponents();
if (!comps)
{
ErrorHandler(E_NO_COMPONENTS);
return E_NO_COMPONENTS;
}
comps = gCtx->sdlg->GetSelectedSetupType()->GetComponents();
if (!sXPInstallEngine) return E_PARAM;
xpiengine = comps->GetCompByArchive(sXPInstallEngine);
// 1> download
err = engine->Download(bCus, comps);
if (err == E_DL_DROP_CXN)
if (bDownload)
{
ShowCxnDroppedDlg();
if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT)
DLPause(NULL, NULL);
return err;
}
else if (err == E_CRC_FAILED)
{
ErrorHandler(err);
goto BAIL;
}
else if (err == E_DL_PAUSE || err == E_DL_CANCEL)
{
DUMP("Pause or Cancel pressed");
goto BAIL;
}
else if (err != OK)
{
DUMP("dammit... hopped into the wrong hole!");
ErrorHandler(err);
goto BAIL;
err = engine->Download(bCus, comps);
if (err == E_DL_DROP_CXN)
{
ShowCxnDroppedDlg();
if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT)
DLPause(NULL, NULL);
return err;
}
else if (err == E_CRC_FAILED)
{
ErrorHandler(err);
goto BAIL;
}
else if (err == E_DL_PAUSE || err == E_DL_CANCEL)
{
DUMP("Pause or Cancel pressed");
goto BAIL;
}
else if (err != OK)
{
DUMP("dammit... hopped into the wrong hole!");
ErrorHandler(err);
goto BAIL;
}
}
// prepare install UI

View File

@ -53,7 +53,6 @@ const char kDLMarkerPath[] = "./xpi/.current_download";
nsXIEngine::nsXIEngine() :
mTmp(NULL),
mTotalComps(0),
mOriginalDir(NULL)
{
}
@ -124,13 +123,6 @@ nsXIEngine::Download(int aCustom, nsComponentList *aComps)
sprintf(localPath, "%s/%s", XPI_DIR, markedComp->GetArchive());
markedComp->SetResumePos(GetFileSize(localPath));
}
else
{
// if all .xpis exist in the ./xpi dir (blob/CD)
// we don't need to download
if (ExistAllXPIs(aCustom, aComps, &mTotalComps))
return OK;
}
// check if ./xpi dir exists else create it
if (0 != stat(XPI_DIR, &stbuf))
@ -504,11 +496,14 @@ nsXIEngine::Install(int aCustom, nsComponentList *aComps, char *aDestination)
char new_LD_LIBRARY_PATH[MAXPATHLEN];
int i;
int compNum = 1;
int numComps;
nsComponent *currComp = NULL;
if (!aComps || !aDestination)
return E_PARAM;
numComps = aCustom ? aComps->GetLengthSelected() : aComps->GetLength();
// handle LD_LIBRARY_PATH settings
#if defined (SOLARIS) || defined (IRIX)
sprintf(new_LD_LIBRARY_PATH, "LD_LIBRARY_PATH=%s/bin:.", mTmp);
@ -542,7 +537,7 @@ nsXIEngine::Install(int aCustom, nsComponentList *aComps, char *aDestination)
{
if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT)
nsInstallDlg::MajorProgressCB(currComp->GetDescShort(),
compNum, mTotalComps, nsInstallDlg::ACT_INSTALL);
compNum, numComps, nsInstallDlg::ACT_INSTALL);
err = InstallXPI(currComp, &stub);
if (err != OK)
if (err == E_INSTALL)
@ -750,12 +745,10 @@ nsXIEngine::ProgressCallback(const char* aMsg, PRInt32 aVal, PRInt32 aMax)
}
int
nsXIEngine::ExistAllXPIs(int aCustom, nsComponentList *aComps, int *aTotal)
nsXIEngine::ExistAllXPIs(int aCustom, nsComponentList *aComps)
{
// param check
if (!aComps || !aTotal)
return E_PARAM;
DUMP("ExistAllXPIs");
int bAllExist = TRUE;
nsComponent *currComp = aComps->GetHead();
char currArchivePath[256];
@ -768,12 +761,11 @@ nsXIEngine::ExistAllXPIs(int aCustom, nsComponentList *aComps, int *aTotal)
sprintf(currArchivePath, "%s/%s", XPI_DIR, currComp->GetArchive());
DUMP(currArchivePath);
if (0 != stat(currArchivePath, &dummy))
if (0 != stat(currArchivePath, &dummy)
|| VerifyArchive(currArchivePath) != ZIP_OK)
bAllExist = FALSE;
else
currComp->SetDownloaded(TRUE);
(*aTotal)++;
}
currComp = aComps->GetNext();

View File

@ -107,7 +107,7 @@ public:
int DeleteXPIs(int aCustom, nsComponentList *aComps);
static void ProgressCallback(const char* aMsg, PRInt32 aVal, PRInt32 aMax);
static int ExistAllXPIs(int aCustom, nsComponentList *aComps, int *aTotal);
static int ExistAllXPIs(int aCustom, nsComponentList *aComps);
enum
{
@ -134,10 +134,11 @@ private:
PRBool CRCCheckDownloadedArchives(char *dlPath, short dlPathLen,
nsComponentList *aComps, int aCustom);
PRBool IsArchiveFile(char *path);
int VerifyArchive(char *szArchive);
PRBool CheckConn( char *URL, int type, CONN *myConn, PRBool force );
static int VerifyArchive(char *szArchive);
char *mTmp;
int mTotalComps;
char *mOriginalDir;
};