Fix ignoreFreeDiskSpaceChecks() usage

Now actually ignore free space, instead of creating an error and refusing to go further everytime

--HG--
branch : fix_freespace_check
This commit is contained in:
Guillaume Dupuy 2017-07-15 12:14:33 +02:00
parent 9172d14dd3
commit d163cde51e
2 changed files with 8 additions and 6 deletions

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;