Linux: do not trust device write stats if higher than what we wrote
For reasons unknown the device write statistics sometimes report higher numbers than the number of bytes we wrote to the device on some hardware. Causing write percentage in progressbar text to exceed 100% Maximize amount of bytes to what we wrote to the device. This do will result in unreliable write progress on these devices (it will then show amount of bytes written to cache instead of what made it to device yet) Closes #82
This commit is contained in:
@@ -515,7 +515,7 @@ uint64_t DownloadThread::verifyTotal()
|
||||
uint64_t DownloadThread::bytesWritten()
|
||||
{
|
||||
if (_sectorsStart != -1)
|
||||
return (_sectorsWritten()-_sectorsStart)*512;
|
||||
return qMin((uint64_t) (_sectorsWritten()-_sectorsStart)*512, (uint64_t) _bytesWritten);
|
||||
else
|
||||
return _bytesWritten;
|
||||
}
|
||||
@@ -619,7 +619,8 @@ bool DownloadThread::_verify()
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
/* Make sure we are reading from the drive and not from cache */
|
||||
fcntl(_file.handle(), F_SETFL, O_DIRECT | fcntl(_file.handle(), F_GETFL));
|
||||
//fcntl(_file.handle(), F_SETFL, O_DIRECT | fcntl(_file.handle(), F_GETFL));
|
||||
posix_fadvise(_file.handle(), 0, 0, POSIX_FADV_DONTNEED);
|
||||
#endif
|
||||
|
||||
if (!_firstBlock)
|
||||
|
Reference in New Issue
Block a user