Merge with develop

--HG--
branch : compatibility-develop
This commit is contained in:
kervala 2016-10-18 17:47:19 +02:00
commit 9b70baf02b
2 changed files with 63 additions and 42 deletions

View file

@ -377,10 +377,14 @@ void clientAuthentication(CMessage &msgin, TSockId from, CCallbackNetBase &netba
{
if (!Clients[i]->Authentificated && Clients[i]->getSock() == from)
{
if (!Clients[i]->BadLogin) // don't allow new login attempt while thisflag is set
if (!Clients[i]->BadLogin) // don't allow new login attempt while this flag is set
{
// escape login
char esccapedLogin[100];
size_t len = mysql_real_escape_string(DatabaseConnection, esccapedLogin, login.c_str(), login.length());
// make a db request to to db to see if password is valid
std::string queryStr = toString("SELECT Password FROM user where Login='%s'", login.c_str());
std::string queryStr = toString("SELECT Password FROM user where Login='%s'", esccapedLogin);
int result = mysql_query(DatabaseConnection, queryStr.c_str());
if (result == 0)
{

View file

@ -408,28 +408,53 @@ bool CFilesExtractor::extract7z()
QString path = QString::fromUtf16(temp);
QString filename = QFileInfo(path).fileName();
if (!isDir)
QString destPath = m_destinationDirectory + '/' + path;
// get uncompressed size
quint64 uncompressedSize = SzArEx_GetFileSize(&db, i);
// get modification time
quint32 modificationTime = 0;
if (SzBitWithVals_Check(&db.MTime, i))
{
modificationTime = convertWindowsFileTimeToUnixTimestamp(db.MTime.Vals[i]);
}
if (isDir)
{
QDir().mkpath(destPath);
continue;
}
// check if file exists
if (QFile::exists(destPath))
{
QFileInfo currentFileInfo(destPath);
// skip file if same size and same modification date
if (currentFileInfo.lastModified().toTime_t() == modificationTime && currentFileInfo.size() == uncompressedSize)
{
// update progress
totalUncompressed += uncompressedSize;
if (m_listener) m_listener->operationProgress(totalUncompressed, filename);
continue;
}
}
if (m_listener) m_listener->operationProgress(totalUncompressed, filename);
res = SzArEx_Extract(&db, &lookStream.s, i, &blockIndex, &outBuffer, &outBufferSize,
&offset, &outSizeProcessed, &allocImp, &allocTempImp);
if (res != SZ_OK) break;
}
QString destPath = m_destinationDirectory + '/' + path;
QDir dir;
if (isDir)
{
dir.mkpath(destPath);
continue;
}
dir.mkpath(QFileInfo(destPath).absolutePath());
// create file directory
QDir().mkpath(QFileInfo(destPath).absolutePath());
// create file
QFile outFile(destPath);
if (!outFile.open(QFile::WriteOnly))
@ -446,10 +471,7 @@ bool CFilesExtractor::extract7z()
qint64 currentProcessedSize = outFile.write((const char*)(outBuffer + offset), currentSizeToProcess);
// errors only occur when returned size is -1
if (currentProcessedSize < 0)
{
break;
}
if (currentProcessedSize < 0) break;
offset += currentProcessedSize;
currentSizeToProcess -= currentProcessedSize;
@ -465,27 +487,22 @@ bool CFilesExtractor::extract7z()
outFile.close();
totalUncompressed += SzArEx_GetFileSize(&db, i);
totalUncompressed += uncompressedSize;
if (m_listener) m_listener->operationProgress(totalUncompressed, filename);
// set attrinbutes
// set attributes
if (SzBitWithVals_Check(&db.Attribs, i))
{
Set7zFileAttrib(destPath, db.Attribs.Vals[i]);
}
// set modification time
if (SzBitWithVals_Check(&db.MTime, i))
{
char buffer[1024];
if (!NLMISC::CFile::setFileModificationDate(qToUtf8(destPath), convertWindowsFileTimeToUnixTimestamp(db.MTime.Vals[i])))
if (!NLMISC::CFile::setFileModificationDate(qToUtf8(destPath), modificationTime))
{
qDebug() << "Unable to change date of " << destPath;
}
}
}
IAlloc_Free(&allocImp, outBuffer);
}