|
|
@ -1354,7 +1354,7 @@ void CPatchManager::getServerFile (const std::string &name, bool bZipped, const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//nlwarning("EXCEPTION CATCH: getServerFile() failed - try to find an alternative: %i: %s",UsedServer,PatchServers[UsedServer].DisplayedServerPath.c_str());
|
|
|
|
//nlwarning("EXCEPTION CATCH: getServerFile() failed - try to find an alternative: %i: %s",UsedServer,PatchServers[UsedServer].DisplayedServerPath.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
nlwarning("EXCEPTION CATCH: getServerFile() failed - try to find an alternative :");
|
|
|
|
nlwarning("EXCEPTION CATCH: getServerFile() failed - try to find an alternative : %s", (serverPath+srcName).c_str());
|
|
|
|
nlwarning("%i", UsedServer);
|
|
|
|
nlwarning("%i", UsedServer);
|
|
|
|
if (UsedServer >= 0 && UsedServer < (int) PatchServers.size())
|
|
|
|
if (UsedServer >= 0 && UsedServer < (int) PatchServers.size())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -2676,6 +2676,7 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP)
|
|
|
|
|
|
|
|
|
|
|
|
string OutFilename;
|
|
|
|
string OutFilename;
|
|
|
|
bool usePatchFile = true;
|
|
|
|
bool usePatchFile = true;
|
|
|
|
|
|
|
|
bool haveAllreadyTryiedDownloadingOfFile = false;
|
|
|
|
|
|
|
|
|
|
|
|
// compute the total size of patch to download
|
|
|
|
// compute the total size of patch to download
|
|
|
|
uint32 totalPatchSize = 0;
|
|
|
|
uint32 totalPatchSize = 0;
|
|
|
@ -2743,6 +2744,7 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// can not load the 7zip file, use normal patching
|
|
|
|
// can not load the 7zip file, use normal patching
|
|
|
|
usePatchFile = true;
|
|
|
|
usePatchFile = true;
|
|
|
|
|
|
|
|
haveAllreadyTryiedDownloadingOfFile = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2754,6 +2756,7 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// fallback to standard patch method
|
|
|
|
// fallback to standard patch method
|
|
|
|
usePatchFile = true;
|
|
|
|
usePatchFile = true;
|
|
|
|
|
|
|
|
haveAllreadyTryiedDownloadingOfFile = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2766,6 +2769,7 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP)
|
|
|
|
nlwarning("Failed to unpack lzma file %s", (pPM->ClientPatchPath+lzmaFile).c_str());
|
|
|
|
nlwarning("Failed to unpack lzma file %s", (pPM->ClientPatchPath+lzmaFile).c_str());
|
|
|
|
// fallback to standard patch method
|
|
|
|
// fallback to standard patch method
|
|
|
|
usePatchFile = true;
|
|
|
|
usePatchFile = true;
|
|
|
|
|
|
|
|
haveAllreadyTryiedDownloadingOfFile = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2874,8 +2878,83 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP)
|
|
|
|
sTranslate = CI18N::get("uiApplyingDelta") + " " + CFile::getFilename(PatchName);
|
|
|
|
sTranslate = CI18N::get("uiApplyingDelta") + " " + CFile::getFilename(PatchName);
|
|
|
|
pPM->setState(true, sTranslate);
|
|
|
|
pPM->setState(true, sTranslate);
|
|
|
|
|
|
|
|
|
|
|
|
xDeltaPatch(PatchName, SourceNameXD, OutFilename);
|
|
|
|
bool deltaPatchResult = xDeltaPatch(PatchName, SourceNameXD, OutFilename);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!deltaPatchResult && !haveAllreadyTryiedDownloadingOfFile) // Patch failed, try to download and apply lzma
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
breakable
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// compute the seven zip filename
|
|
|
|
|
|
|
|
string lzmaFile = rFTP.FileName+".lzma";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// download the 7zip file
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// first, try in the file version subfolfer
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
progress.Scale = 1.f;
|
|
|
|
|
|
|
|
progress.Bias = 0.f;
|
|
|
|
|
|
|
|
if (!rFTP.Patches.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pPM->getServerFile(toString("%05u/", rFTP.Patches.back())+lzmaFile, false, "", &progress);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// else -> file comes from a previous download (with .tmp extension, and is up to date)
|
|
|
|
|
|
|
|
// the remaining code will just rename it with good name and exit
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (const NLMISC::EWriteError &)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// this is a local error, rethrow ...
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch(...)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// failed with version subfolder, try in the root patch directory
|
|
|
|
|
|
|
|
pPM->getServerFile(lzmaFile, false, "", &progress);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (const NLMISC::EWriteError &)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// this is a local error, rethrow ...
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OutFilename = pPM->ClientPatchPath + NLMISC::CFile::getFilename(rFTP.FileName);
|
|
|
|
|
|
|
|
// try to unpack the file
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!unpackLZMA(pPM->ClientPatchPath+lzmaFile, OutFilename+".tmp"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (const NLMISC::EWriteError&)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlwarning("Failed to unpack lzma file %s", (pPM->ClientPatchPath+lzmaFile).c_str());
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rFTP.LocalFileExists)
|
|
|
|
|
|
|
|
pPM->deleteFile(SourceName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pPM->deleteFile(pPM->ClientPatchPath+lzmaFile); // delete the archive file
|
|
|
|
|
|
|
|
pPM->deleteFile(SourceName, false, false); // File can exists if bad BNP loading
|
|
|
|
|
|
|
|
if (_CommitPatch)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pPM->renameFile(OutFilename+".tmp", DestinationName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
if (rFTP.LocalFileExists)
|
|
|
|
if (rFTP.LocalFileExists)
|
|
|
|
pPM->deleteFile(SourceName);
|
|
|
|
pPM->deleteFile(SourceName);
|
|
|
|
pPM->deleteFile(PatchName);
|
|
|
|
pPM->deleteFile(PatchName);
|
|
|
@ -2903,6 +2982,7 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PatchSizeProgress += totalPatchSize;
|
|
|
|
PatchSizeProgress += totalPatchSize;
|
|
|
@ -2915,7 +2995,7 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ****************************************************************************
|
|
|
|
// ****************************************************************************
|
|
|
|
void CPatchThread::xDeltaPatch(const string &patch, const string &src, const string &out)
|
|
|
|
bool CPatchThread::xDeltaPatch(const string &patch, const string &src, const string &out)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Internal xdelta
|
|
|
|
// Internal xdelta
|
|
|
|
|
|
|
|
|
|
|
@ -2941,12 +3021,13 @@ void CPatchThread::xDeltaPatch(const string &patch, const string &src, const str
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string str = toString("Error applying %s to %s giving %s", patch.c_str(), src.c_str(), out.c_str());
|
|
|
|
nlinfo("Error applying %s to %s giving %s", patch.c_str(), src.c_str(), out.c_str());
|
|
|
|
throw Exception (str);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Launching xdelta
|
|
|
|
// Launching xdelta
|
|
|
|