зеркало из https://github.com/mozilla/gecko-dev.git
nativepatch() returns new patched file to the caller function
make final file replacement work for patch files
This commit is contained in:
Родитель
86dcb0785c
Коммит
0d3c2ceb5f
|
@ -228,7 +228,7 @@ REGERR ReplaceFileNowOrSchedule(nsFileSpec& replacementFile, nsFileSpec& doomedF
|
||||||
|
|
||||||
if ( !doomedFile.Exists() )
|
if ( !doomedFile.Exists() )
|
||||||
{
|
{
|
||||||
// Now that we have move the existing file, we can move the mExtracedFile into place.
|
// Now that we have removed the existing file, we can move the mExtracedFile or mPatchedFile into place.
|
||||||
nsFileSpec parentofFinalFile;
|
nsFileSpec parentofFinalFile;
|
||||||
|
|
||||||
doomedFile.GetParent(parentofFinalFile);
|
doomedFile.GetParent(parentofFinalFile);
|
||||||
|
|
|
@ -906,6 +906,8 @@ nsInstall::Patch(const nsString& aRegName, const nsString& aVersion, const nsStr
|
||||||
qualifiedRegName,
|
qualifiedRegName,
|
||||||
aVersion,
|
aVersion,
|
||||||
aJarSource,
|
aJarSource,
|
||||||
|
aFolder,
|
||||||
|
aTargetName,
|
||||||
&result);
|
&result);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1041,11 +1043,11 @@ nsInstall::AddPatch(nsHashKey *aKey, nsFileSpec* fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsInstall::GetPatch(nsHashKey *aKey, nsFileSpec* fileName)
|
nsInstall::GetPatch(nsHashKey *aKey, nsFileSpec** fileName)
|
||||||
{
|
{
|
||||||
if (mPatchList != nsnull)
|
if (mPatchList != nsnull)
|
||||||
{
|
{
|
||||||
fileName = (nsFileSpec*) mPatchList->Get(aKey);
|
*fileName = (nsFileSpec*) mPatchList->Get(aKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ class nsInstall
|
||||||
|
|
||||||
PRInt32 ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedName, nsFileSpec** aRealName);
|
PRInt32 ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedName, nsFileSpec** aRealName);
|
||||||
void AddPatch(nsHashKey *aKey, nsFileSpec* fileName);
|
void AddPatch(nsHashKey *aKey, nsFileSpec* fileName);
|
||||||
void GetPatch(nsHashKey *aKey, nsFileSpec* fileName);
|
void GetPatch(nsHashKey *aKey, nsFileSpec** fileName);
|
||||||
|
|
||||||
void GetJarFileLocation(nsString& aFile);
|
void GetJarFileLocation(nsString& aFile);
|
||||||
void SetJarFileLocation(const nsString& aFile);
|
void SetJarFileLocation(const nsString& aFile);
|
||||||
|
|
|
@ -184,7 +184,7 @@ PRInt32 nsInstallPatch::Prepare()
|
||||||
nsFileSpec *fileName = nsnull;
|
nsFileSpec *fileName = nsnull;
|
||||||
nsVoidKey ikey( HashFilePath( nsFilePath(*mTargetFile) ) );
|
nsVoidKey ikey( HashFilePath( nsFilePath(*mTargetFile) ) );
|
||||||
|
|
||||||
mInstall->GetPatch(&ikey, fileName);
|
mInstall->GetPatch(&ikey, &fileName);
|
||||||
|
|
||||||
if (fileName != nsnull)
|
if (fileName != nsnull)
|
||||||
{
|
{
|
||||||
|
@ -228,12 +228,12 @@ PRInt32 nsInstallPatch::Complete()
|
||||||
nsFileSpec *fileName = nsnull;
|
nsFileSpec *fileName = nsnull;
|
||||||
nsVoidKey ikey( HashFilePath( nsFilePath(*mTargetFile) ) );
|
nsVoidKey ikey( HashFilePath( nsFilePath(*mTargetFile) ) );
|
||||||
|
|
||||||
mInstall->GetPatch(&ikey, fileName);
|
mInstall->GetPatch(&ikey, &fileName);
|
||||||
|
|
||||||
if (fileName != nsnull && (*fileName == *mPatchedFile) )
|
if (fileName != nsnull && (*fileName == *mPatchedFile) )
|
||||||
{
|
{
|
||||||
// the patch has not been superceded--do final replacement
|
// the patch has not been superceded--do final replacement
|
||||||
err = ReplaceFileNowOrSchedule( *mTargetFile, *mPatchedFile);
|
err = ReplaceFileNowOrSchedule( *mPatchedFile, *mTargetFile);
|
||||||
if ( 0 == err || nsInstall::REBOOT_NEEDED == err )
|
if ( 0 == err || nsInstall::REBOOT_NEEDED == err )
|
||||||
{
|
{
|
||||||
nsString tempVersionString;
|
nsString tempVersionString;
|
||||||
|
@ -270,7 +270,7 @@ void nsInstallPatch::Abort()
|
||||||
nsFileSpec *fileName = nsnull;
|
nsFileSpec *fileName = nsnull;
|
||||||
nsVoidKey ikey( HashFilePath( nsFilePath(*mTargetFile) ) );
|
nsVoidKey ikey( HashFilePath( nsFilePath(*mTargetFile) ) );
|
||||||
|
|
||||||
mInstall->GetPatch(&ikey, fileName);
|
mInstall->GetPatch(&ikey, &fileName);
|
||||||
|
|
||||||
if (fileName != nsnull && (*fileName == *mPatchedFile) )
|
if (fileName != nsnull && (*fileName == *mPatchedFile) )
|
||||||
{
|
{
|
||||||
|
@ -309,7 +309,14 @@ nsInstallPatch::NativePatch(const nsFileSpec &sourceFile, const nsFileSpec &patc
|
||||||
PRInt32 status = GDIFF_ERR_MEM;
|
PRInt32 status = GDIFF_ERR_MEM;
|
||||||
char *tmpurl = NULL;
|
char *tmpurl = NULL;
|
||||||
char *realfile = PL_strdup(nsNSPRPath(sourceFile)); // needs to be sourceFile!!!
|
char *realfile = PL_strdup(nsNSPRPath(sourceFile)); // needs to be sourceFile!!!
|
||||||
nsFileSpec outFileSpec = sourceFile;
|
nsFileSpec *outFileSpec = new nsFileSpec;
|
||||||
|
|
||||||
|
if (!outFileSpec) {
|
||||||
|
status = GDIFF_ERR_MEM;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
*outFileSpec = sourceFile;
|
||||||
|
|
||||||
dd = (DIFFDATA *)PR_Calloc( 1, sizeof(DIFFDATA));
|
dd = (DIFFDATA *)PR_Calloc( 1, sizeof(DIFFDATA));
|
||||||
if (dd != NULL)
|
if (dd != NULL)
|
||||||
|
@ -405,10 +412,10 @@ nsInstallPatch::NativePatch(const nsFileSpec &sourceFile, const nsFileSpec &patc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
outFileSpec.SetLeafName(newFileName); //????
|
outFileSpec->SetLeafName(newFileName);
|
||||||
outFileSpec.MakeUnique();
|
outFileSpec->MakeUnique();
|
||||||
|
|
||||||
char *outFile = PL_strdup(nsNSPRPath(outFileSpec));
|
char *outFile = PL_strdup(nsNSPRPath(*outFileSpec));
|
||||||
|
|
||||||
// apply patch to the source file
|
// apply patch to the source file
|
||||||
dd->fSrc = PR_Open ( realfile, PR_RDONLY, 0666);
|
dd->fSrc = PR_Open ( realfile, PR_RDONLY, 0666);
|
||||||
|
@ -433,7 +440,7 @@ nsInstallPatch::NativePatch(const nsFileSpec &sourceFile, const nsFileSpec &patc
|
||||||
|
|
||||||
if (status == GDIFF_OK)
|
if (status == GDIFF_OK)
|
||||||
{
|
{
|
||||||
*newFile = &outFileSpec;
|
*newFile = outFileSpec;
|
||||||
if ( outFile != nsnull)
|
if ( outFile != nsnull)
|
||||||
PL_strfree( outFile );
|
PL_strfree( outFile );
|
||||||
}
|
}
|
||||||
|
@ -450,16 +457,16 @@ nsInstallPatch::NativePatch(const nsFileSpec &sourceFile, const nsFileSpec &patc
|
||||||
if ( dd->bMacAppleSingle && status == GDIFF_OK )
|
if ( dd->bMacAppleSingle && status == GDIFF_OK )
|
||||||
{
|
{
|
||||||
// create another file, so that we can decode somewhere
|
// create another file, so that we can decode somewhere
|
||||||
nsFileSpec anotherName = outFileSpec;
|
nsFileSpec *anotherName = outFileSpec;
|
||||||
anotherName.MakeUnique();
|
anotherName->MakeUnique();
|
||||||
|
|
||||||
// Close the out file so that we can read it
|
// Close the out file so that we can read it
|
||||||
PR_Close( dd->fOut );
|
PR_Close( dd->fOut );
|
||||||
dd->fOut = NULL;
|
dd->fOut = NULL;
|
||||||
|
|
||||||
|
|
||||||
FSSpec outSpec = outFileSpec.GetFSSpec();
|
FSSpec outSpec = outFileSpec->GetFSSpec();
|
||||||
FSSpec anotherSpec = anotherName.GetFSSpec();
|
FSSpec anotherSpec = anotherName->GetFSSpec();
|
||||||
|
|
||||||
|
|
||||||
status = PAS_DecodeFile(&outSpec, &anotherSpec);
|
status = PAS_DecodeFile(&outSpec, &anotherSpec);
|
||||||
|
@ -470,12 +477,12 @@ nsInstallPatch::NativePatch(const nsFileSpec &sourceFile, const nsFileSpec &patc
|
||||||
|
|
||||||
nsFileSpec parent;
|
nsFileSpec parent;
|
||||||
|
|
||||||
outFileSpec.GetParent(parent);
|
outFileSpec->GetParent(parent);
|
||||||
|
|
||||||
outFileSpec.Delete(PR_FALSE);
|
outFileSpec->Delete(PR_FALSE);
|
||||||
anotherName.Copy(parent);
|
anotherName->Copy(parent);
|
||||||
|
|
||||||
*newFile = &anotherName;
|
*newFile = anotherName;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче