r22668 by jghali - refactor util_file.cpp's checkFileHash()

scribus-commit scribus-commit at lists.scribus.net
Tue Sep 4 23:22:04 UTC 2018


Author: jghali
Date: Tue Sep  4 23:22:04 2018
New Revision: 22668

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22668
Log:
refactor util_file.cpp's checkFileHash()

Modified:
    trunk/Scribus/scribus/util_file.cpp

Modified: trunk/Scribus/scribus/util_file.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22668&path=/trunk/Scribus/scribus/util_file.cpp
==============================================================================
--- trunk/Scribus/scribus/util_file.cpp	(original)
+++ trunk/Scribus/scribus/util_file.cpp	Tue Sep  4 23:22:04 2018
@@ -290,22 +290,23 @@
 	//In a single directory, make a hash of filename, and compare it to the string for that file in hashFilename
 	//Assumption is that the hash file only has one line for now
 	QByteArray ba_hash;
-	if (loadRawText(directory + hashFilename, ba_hash))
-	{
-		QFile source(directory + filename);
-		if (source.open(QIODevice::ReadOnly))
-		{
-			ba_hash = ba_hash.simplified();
-			QList<QByteArray> fileData(ba_hash.split(' '));
-			QCryptographicHash ch(method);
-			ch.addData(&source);
-			source.close();
-			if (fileData[0] == ch.result().toHex() && fileData[1] == filename)
-				return true;
-			qDebug()<<"checkFileHash: checksum failed for"<<directory<<filename;
-		}
-	}
-	else
-		qDebug()<<"checkFileHash: loadRawText file unsuccessful";
+	if (!loadRawText(directory + hashFilename, ba_hash))
+	{
+		qDebug() << "checkFileHash: loadRawText file unsuccessful";
+		return false;
+	}
+
+	QFile source(directory + filename);
+	if (source.open(QIODevice::ReadOnly))
+	{
+		ba_hash = ba_hash.simplified();
+		QList<QByteArray> fileData(ba_hash.split(' '));
+		QCryptographicHash ch(method);
+		ch.addData(&source);
+		source.close();
+		if (fileData[0] == ch.result().toHex() && fileData[1] == filename)
+			return true;
+		qDebug()<<"checkFileHash: checksum failed for"<<directory<<filename;
+	}
 	return false;
 }




More information about the scribus-commit mailing list