TransmissionChecksum: Removed "pseudo" thread worker functions

Removed the Worker postfix from the method names to reflect their non
threaded character, they moved into a thread in the Validator class.

Thanks ckamm for review.
This commit is contained in:
Klaas Freitag 2015-05-20 10:45:20 +02:00
parent 4d87f30434
commit 1f7274c2f2
3 changed files with 9 additions and 45 deletions

View file

@ -402,7 +402,7 @@ QString FileSystem::fileSystemForPath(const QString & path)
}
#endif
QByteArray FileSystem::calcMd5Worker( const QString& filename )
QByteArray FileSystem::calcMd5( const QString& filename )
{
QByteArray arr;
@ -420,7 +420,7 @@ QByteArray FileSystem::calcMd5Worker( const QString& filename )
return arr;
}
QByteArray FileSystem::calcSha1Worker( const QString& filename )
QByteArray FileSystem::calcSha1( const QString& filename )
{
QByteArray arr;
@ -439,7 +439,7 @@ QByteArray FileSystem::calcSha1Worker( const QString& filename )
}
#ifdef ZLIB_FOUND
QByteArray FileSystem::calcAdler32Worker( const QString& filename )
QByteArray FileSystem::calcAdler32( const QString& filename )
{
unsigned int adler = adler32(0L, Z_NULL, 0);
@ -456,36 +456,4 @@ QByteArray FileSystem::calcAdler32Worker( const QString& filename )
}
#endif
QByteArray FileSystem::calcMd5( const QString& fileName )
{
QFuture<QByteArray> f1 = QtConcurrent::run(calcMd5Worker, fileName );
f1.waitForFinished();
const QByteArray md5 = f1.result();
return md5;
}
QByteArray FileSystem::calcSha1( const QString& fileName )
{
QFuture<QByteArray> f1 = QtConcurrent::run(calcSha1Worker, fileName );
f1.waitForFinished();
const QByteArray sha1 = f1.result();
return sha1;
}
#ifdef ZLIB_FOUND
QByteArray FileSystem::calcAdler32( const QString& fileName )
{
QFuture<QByteArray> f1 = QtConcurrent::run(calcAdler32Worker, fileName );
f1.waitForFinished();
const QByteArray checksum = f1.result();
return checksum;
}
#endif
} // namespace OCC

View file

@ -121,10 +121,6 @@ bool openAndSeekFileSharedRead(QFile* file, QString* error, qint64 seek);
QString fileSystemForPath(const QString & path);
#endif
/**
* Calculate the checksum of a file in a worker thread. Each function waits
* until the calculation is finished.
*/
QByteArray calcMd5( const QString& fileName );
QByteArray calcSha1( const QString& fileName );
QByteArray calcAdler32( const QString& fileName );

View file

@ -59,18 +59,18 @@ void TransmissionChecksumValidator::uploadValidation( SyncFileItem *item )
if( checksumType == checkSumMD5C ) {
item->_checksum = checkSumMD5C;
item->_checksum += ":";
_watcher.setFuture(QtConcurrent::run(FileSystem::calcMd5Worker, _filePath));
_watcher.setFuture(QtConcurrent::run(FileSystem::calcMd5, _filePath));
} else if( checksumType == checkSumSHA1C ) {
item->_checksum = checkSumSHA1C;
item->_checksum += ":";
_watcher.setFuture(QtConcurrent::run( FileSystem::calcSha1Worker, _filePath));
_watcher.setFuture(QtConcurrent::run( FileSystem::calcSha1, _filePath));
}
#ifdef ZLIB_FOUND
else if( checksumType == checkSumAdlerC) {
item->_checksum = checkSumAdlerC;
item->_checksum += ":";
_watcher.setFuture(QtConcurrent::run(FileSystem::calcAdler32Worker, _filePath));
_watcher.setFuture(QtConcurrent::run(FileSystem::calcAdler32, _filePath));
}
#endif
else {
@ -117,13 +117,13 @@ void TransmissionChecksumValidator::downloadValidation( const QByteArray& checks
// start the calculation in different thread
if( type == checkSumMD5C ) {
_watcher.setFuture(QtConcurrent::run(FileSystem::calcMd5Worker, _filePath));
_watcher.setFuture(QtConcurrent::run(FileSystem::calcMd5, _filePath));
} else if( type == checkSumSHA1C ) {
_watcher.setFuture(QtConcurrent::run(FileSystem::calcSha1Worker, _filePath));
_watcher.setFuture(QtConcurrent::run(FileSystem::calcSha1, _filePath));
}
#ifdef ZLIB_FOUND
else if( type == checkSumAdlerUpperC ) {
_watcher.setFuture(QtConcurrent::run(FileSystem::calcAdler32Worker, _filePath));
_watcher.setFuture(QtConcurrent::run(FileSystem::calcAdler32, _filePath));
}
#endif
else {