Merge with develop

--HG--
branch : compatibility-develop
hg/compatibility-develop
Nimetu 7 years ago
commit 655dee03b4

@ -366,8 +366,11 @@ namespace NLGUI
time_t currentTime;
time(&currentTime);
CHttpCacheObject cache = CHttpCache::getInstance()->lookup(download.dest);
if (CFile::fileExists(download.dest) && cache.Expires > currentTime)
CHttpCacheObject cache;
if (CFile::fileExists(download.dest))
cache = CHttpCache::getInstance()->lookup(download.dest);
if (cache.Expires > currentTime)
{
#ifdef LOG_DL
nlwarning("Cache for (%s) is not expired (%s, expires:%d)", download.url.c_str(), download.dest.c_str(), cache.Expires - currentTime);
@ -450,6 +453,19 @@ namespace NLGUI
{
string finalUrl = upgradeInsecureUrl(getAbsoluteUrl(url));
// use requested url for local name (cache)
string dest = localImageName(url);
#ifdef LOG_DL
nlwarning("add to download '%s' dest '%s' img %p", finalUrl.c_str(), dest.c_str(), img);
#endif
// Display cached image while downloading new
if (type != TImageType::OverImage && CFile::fileExists(dest))
{
setImage(img, dest, type);
setImageSize(img, style);
}
// Search if we are not already downloading this url.
for(uint i = 0; i < Curls.size(); i++)
{
@ -463,12 +479,6 @@ namespace NLGUI
}
}
// use requested url for local name (cache)
string dest = localImageName(url);
#ifdef LOG_DL
nlwarning("add to download '%s' dest '%s' img %p", finalUrl.c_str(), dest.c_str(), img);
#endif
Curls.push_back(CDataDownload(finalUrl, dest, ImgType, img, "", "", style, type));
if (Curls.size() < options.curlMaxConnections) {
if (!startCurlDownload(Curls.back()))
@ -1767,7 +1777,7 @@ namespace NLGUI
tooltip = value[MY_HTML_IMG_TITLE];
// Mouse over image
const char *overSrc = value[MY_HTML_IMG_SRC];
string overSrc;
if (present[MY_HTML_IMG_DATA_OVER_SRC] && value[MY_HTML_IMG_DATA_OVER_SRC])
{
overSrc = value[MY_HTML_IMG_DATA_OVER_SRC];
@ -1781,7 +1791,7 @@ namespace NLGUI
overSrc, "browse", params.c_str(), tooltip, style);
}
else
if (tooltip || overSrc)
if (tooltip || !overSrc.empty())
{
addButton(CCtrlButton::PushButton, value[MY_HTML_IMG_SRC], value[MY_HTML_IMG_SRC], value[MY_HTML_IMG_SRC],
overSrc, "", "", tooltip, style);

@ -1390,7 +1390,7 @@ uint64 CSystemInfo::availableHDSpace (const string &filename)
struct statfs stfs;
if (::statfs(path.c_str(), &stfs) != 0) return 0;
return (uint64)(stfs.f_bavail * stfs.f_bsize);
return (uint64)stfs.f_bavail * (uint64)stfs.f_bsize;
#else
ULARGE_INTEGER freeSpace = {0};
BOOL bRes = ::GetDiskFreeSpaceExW(utf8ToWide(path), &freeSpace, NULL, NULL);

@ -180,9 +180,10 @@ void CDownloader::getFileHead()
void CDownloader::downloadFile()
{
qint64 freeSpace = CConfigFile::getInstance()->ignoreFreeDiskSpaceChecks() ? 0:NLMISC::CSystemInfo::availableHDSpace(m_fullPath.toUtf8().constData());
bool ignoreFreeDiskSpaceChecks = CConfigFile::getInstance()->ignoreFreeDiskSpaceChecks();
qint64 freeSpace = NLMISC::CSystemInfo::availableHDSpace(m_fullPath.toUtf8().constData());
if (freeSpace == 0)
if (!ignoreFreeDiskSpaceChecks && freeSpace == 0)
{
if (m_listener)
{
@ -192,7 +193,7 @@ void CDownloader::downloadFile()
return;
}
if (freeSpace < m_size - m_offset)
if (!ignoreFreeDiskSpaceChecks && freeSpace < m_size - m_offset)
{
// we have not enough free disk space to continue download
if (m_listener) m_listener->operationFail(tr("You only have %1 bytes left on the device, but %2 bytes are needed.").arg(freeSpace).arg(m_size - m_offset));

@ -123,10 +123,11 @@ void CMigrateDialog::updateDestinationText()
void CMigrateDialog::accept()
{
// check free disk space
qint64 freeSpace = CConfigFile::getInstance()->ignoreFreeDiskSpaceChecks() ? 0:NLMISC::CSystemInfo::availableHDSpace(m_dstDirectory.toUtf8().constData());
bool ignoreFreeDiskSpaceChecks = CConfigFile::getInstance()->ignoreFreeDiskSpaceChecks();
qint64 freeSpace = NLMISC::CSystemInfo::availableHDSpace(m_dstDirectory.toUtf8().constData());
// shouldn't happen
if (freeSpace == 0)
if (!ignoreFreeDiskSpaceChecks && freeSpace == 0)
{
int error = NLMISC::getLastError();
@ -134,7 +135,7 @@ void CMigrateDialog::accept()
}
// compare with exact size of current directory
if (freeSpace && freeSpace < getDirectorySize(m_currentDirectory, true))
if (!ignoreFreeDiskSpaceChecks && freeSpace && freeSpace < getDirectorySize(m_currentDirectory, true))
{
QMessageBox::StandardButton res = QMessageBox::warning(this, tr("Not enough free disk space"), tr("You don't have enough free space on this disk, please make more space or choose a directory on another disk."));
return;

Loading…
Cancel
Save