}
// Do checksum validation for the download. If there is no checksum header, the validator
- // will also emit the validated() signal to continue the flow in slot downloadFinished()
+ // will also emit the validated() signal to continue the flow in slot transmissionChecksumValidated()
// as this is (still) also correct.
ValidateChecksumHeader *validator = new ValidateChecksumHeader(this);
connect(validator, SIGNAL(validated(QByteArray,QByteArray)),
- SLOT(downloadFinished()));
+ SLOT(transmissionChecksumValidated(QByteArray,QByteArray)));
connect(validator, SIGNAL(validationFailed(QString)),
SLOT(slotChecksumFail(QString)));
auto checksumHeader = job->reply()->rawHeader(checkSumHeaderC);
}
} // end namespace
+void PropagateDownloadFileQNAM::transmissionChecksumValidated(const QByteArray &checksumType, const QByteArray &checksum)
+{
+ const auto theContentChecksumType = QByteArray("SHA1");
+
+ // Reuse transmission checksum as content checksum.
+ //
+ // We could do this more aggressively and accept both MD5 and SHA1
+ // instead of insisting on the exactly correct checksum type.
+ if (theContentChecksumType == checksumType || theContentChecksumType.isEmpty()) {
+ return contentChecksumComputed(checksumType, checksum);
+ }
+
+ // Compute the content checksum.
+ auto computeChecksum = new ComputeChecksum(this);
+ computeChecksum->setChecksumType(theContentChecksumType);
+
+ connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)),
+ SLOT(contentChecksumComputed(QByteArray,QByteArray)));
+ computeChecksum->start(_tmpFile.fileName());
+}
+
+void PropagateDownloadFileQNAM::contentChecksumComputed(const QByteArray &checksumType, const QByteArray &checksum)
+{
+ _item->_contentChecksum = checksum;
+ _item->_contentChecksumType = checksumType;
+
+ downloadFinished();
+}
+
void PropagateDownloadFileQNAM::downloadFinished()
{
QString fn = _propagator->getFilePath(_item->_file);