Merge branch 'fixes' into yubo

merge-requests/7/merge
Ulukyn 5 years ago
commit 222e2c5f77

@ -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 :");
nlwarning("EXCEPTION CATCH: getServerFile() failed - try to find an alternative : %s", (serverPath+srcName).c_str());
nlwarning("%i", UsedServer);
if (UsedServer >= 0 && UsedServer < (int) PatchServers.size())
{
@ -2676,6 +2676,7 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP)
string OutFilename;
bool usePatchFile = true;
bool haveAllreadyTryiedDownloadingOfFile = false;
// compute the total size of patch to download
uint32 totalPatchSize = 0;
@ -2743,6 +2744,7 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP)
{
// can not load the 7zip file, use normal patching
usePatchFile = true;
haveAllreadyTryiedDownloadingOfFile = true;
break;
}
@ -2754,6 +2756,7 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP)
{
// fallback to standard patch method
usePatchFile = true;
haveAllreadyTryiedDownloadingOfFile = true;
break;
}
}
@ -2766,6 +2769,7 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP)
nlwarning("Failed to unpack lzma file %s", (pPM->ClientPatchPath+lzmaFile).c_str());
// fallback to standard patch method
usePatchFile = true;
haveAllreadyTryiedDownloadingOfFile = true;
break;
}
@ -2874,8 +2878,83 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP)
sTranslate = CI18N::get("uiApplyingDelta") + " " + CFile::getFilename(PatchName);
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)
pPM->deleteFile(SourceName);
pPM->deleteFile(PatchName);
@ -2903,6 +2982,7 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP)
}
}
}
}
else
{
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
@ -2941,12 +3021,13 @@ void CPatchThread::xDeltaPatch(const string &patch, const string &src, const str
break;
default:
{
std::string str = toString("Error applying %s to %s giving %s", patch.c_str(), src.c_str(), out.c_str());
throw Exception (str);
nlinfo("Error applying %s to %s giving %s", patch.c_str(), src.c_str(), out.c_str());
return false;
}
break;
}
}
} else
return true;
// Launching xdelta

@ -547,7 +547,7 @@ private:
void run();
void processFile (CPatchManager::SFileToPatch &rFTP);
void xDeltaPatch(const std::string &patch, const std::string &src, const std::string &out);
bool xDeltaPatch(const std::string &patch, const std::string &src, const std::string &out);
};
/**

Loading…
Cancel
Save