Esempio n. 1
0
void PropagateUploadFileQNAM::slotComputeContentChecksum()
{
    if (_propagator->_abortRequested.fetchAndAddRelaxed(0)) {
        return;
    }

    const QString filePath = _propagator->getFilePath(_item->_file);

    // remember the modtime before checksumming to be able to detect a file
    // change during the checksum calculation
    _item->_modtime = FileSystem::getModTime(filePath);

    _stopWatch.start();

    QByteArray checksumType = contentChecksumType();

    // Maybe the discovery already computed the checksum?
    if (_item->_contentChecksumType == checksumType
            && !_item->_contentChecksum.isEmpty()) {
        slotComputeTransmissionChecksum(checksumType, _item->_contentChecksum);
        return;
    }

    // Compute the content checksum.
    auto computeChecksum = new ComputeChecksum(this);
    computeChecksum->setChecksumType(checksumType);

    connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)),
            SLOT(slotComputeTransmissionChecksum(QByteArray,QByteArray)));
    computeChecksum->start(filePath);
}
Esempio n. 2
0
void PropagateUploadFileQNAM::slotComputeContentChecksum()
{
    if (_propagator->_abortRequested.fetchAndAddRelaxed(0)) {
        return;
    }

    _propagator->_activeJobList.removeOne(this);

    const QString filePath = _propagator->getFilePath(_item->_file);

    // remember the modtime before checksumming to be able to detect a file
    // change during the checksum calculation
    _item->_modtime = FileSystem::getModTime(filePath);

    _stopWatch.start();

    QByteArray contentChecksumType;
    // We currently only do content checksums for the particular .eml case
    // This should be done more generally in the future!
    if (filePath.endsWith(QLatin1String(".eml"), Qt::CaseInsensitive)) {
        contentChecksumType = "MD5";
    }

    // Maybe the discovery already computed the checksum?
    if (_item->_contentChecksumType == contentChecksumType
            && !_item->_contentChecksum.isEmpty()) {
        slotComputeTransmissionChecksum(contentChecksumType, _item->_contentChecksum);
        return;
    }

    // Compute the content checksum.
    auto computeChecksum = new ComputeChecksum(this);
    computeChecksum->setChecksumType(contentChecksumType);

    connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)),
            SLOT(slotComputeTransmissionChecksum(QByteArray,QByteArray)));
    computeChecksum->start(filePath);
}