Merge with develop

--HG--
branch : compatibility-develop
This commit is contained in:
Nimetu 2017-07-23 22:54:14 +03:00
commit 655dee03b4
4 changed files with 29 additions and 17 deletions

View file

@ -366,8 +366,11 @@ namespace NLGUI
time_t currentTime; time_t currentTime;
time(&currentTime); time(&currentTime);
CHttpCacheObject cache = CHttpCache::getInstance()->lookup(download.dest); CHttpCacheObject cache;
if (CFile::fileExists(download.dest) && cache.Expires > currentTime) if (CFile::fileExists(download.dest))
cache = CHttpCache::getInstance()->lookup(download.dest);
if (cache.Expires > currentTime)
{ {
#ifdef LOG_DL #ifdef LOG_DL
nlwarning("Cache for (%s) is not expired (%s, expires:%d)", download.url.c_str(), download.dest.c_str(), cache.Expires - currentTime); 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)); 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. // Search if we are not already downloading this url.
for(uint i = 0; i < Curls.size(); i++) 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)); Curls.push_back(CDataDownload(finalUrl, dest, ImgType, img, "", "", style, type));
if (Curls.size() < options.curlMaxConnections) { if (Curls.size() < options.curlMaxConnections) {
if (!startCurlDownload(Curls.back())) if (!startCurlDownload(Curls.back()))
@ -1767,7 +1777,7 @@ namespace NLGUI
tooltip = value[MY_HTML_IMG_TITLE]; tooltip = value[MY_HTML_IMG_TITLE];
// Mouse over image // 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]) if (present[MY_HTML_IMG_DATA_OVER_SRC] && value[MY_HTML_IMG_DATA_OVER_SRC])
{ {
overSrc = 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); overSrc, "browse", params.c_str(), tooltip, style);
} }
else 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], addButton(CCtrlButton::PushButton, value[MY_HTML_IMG_SRC], value[MY_HTML_IMG_SRC], value[MY_HTML_IMG_SRC],
overSrc, "", "", tooltip, style); overSrc, "", "", tooltip, style);

View file

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

View file

@ -180,9 +180,10 @@ void CDownloader::getFileHead()
void CDownloader::downloadFile() 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) if (m_listener)
{ {
@ -192,7 +193,7 @@ void CDownloader::downloadFile()
return; return;
} }
if (freeSpace < m_size - m_offset) if (!ignoreFreeDiskSpaceChecks && freeSpace < m_size - m_offset)
{ {
// we have not enough free disk space to continue download // 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)); 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));

View file

@ -123,10 +123,11 @@ void CMigrateDialog::updateDestinationText()
void CMigrateDialog::accept() void CMigrateDialog::accept()
{ {
// check free disk space // 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 // shouldn't happen
if (freeSpace == 0) if (!ignoreFreeDiskSpaceChecks && freeSpace == 0)
{ {
int error = NLMISC::getLastError(); int error = NLMISC::getLastError();
@ -134,7 +135,7 @@ void CMigrateDialog::accept()
} }
// compare with exact size of current directory // 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.")); 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; return;