mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-24 05:55:59 +03:00
Make TransmissionChecksumValidator child of the job for auto delete.
That way no explicit memory management is needed as the allocation is freed when the job (parent) is deleted automatically.
This commit is contained in:
parent
17fe4c3b29
commit
5b5a636cc1
4 changed files with 7 additions and 19 deletions
|
@ -489,16 +489,15 @@ void PropagateDownloadFileQNAM::slotGetFinished()
|
|||
// do whatever is needed to add a checksum to the http upload request.
|
||||
// in any case, the validator will emit signal startUpload to let the flow
|
||||
// continue in slotStartUpload here.
|
||||
_validator = new TransmissionChecksumValidator( _tmpFile.fileName() );
|
||||
connect(_validator, SIGNAL(validated()), this, SLOT(downloadFinished()));
|
||||
connect(_validator, SIGNAL(validationFailed(QString)), this, SLOT(slotChecksumFail(QString)));
|
||||
_validator->downloadValidation(job->reply()->rawHeader(checkSumHeaderC));
|
||||
TransmissionChecksumValidator *validator = new TransmissionChecksumValidator(_tmpFile.fileName(), this);
|
||||
connect(validator, SIGNAL(validated()), this, SLOT(downloadFinished()));
|
||||
connect(validator, SIGNAL(validationFailed(QString)), this, SLOT(slotChecksumFail(QString)));
|
||||
validator->downloadValidation(job->reply()->rawHeader(checkSumHeaderC));
|
||||
|
||||
}
|
||||
|
||||
void PropagateDownloadFileQNAM::slotChecksumFail( const QString& errMsg )
|
||||
{
|
||||
_validator->deleteLater();
|
||||
_tmpFile.remove();
|
||||
_propagator->_anotherSyncNeeded = true;
|
||||
done(SyncFileItem::SoftError, errMsg ); // tr("The file downloaded with a broken checksum, will be redownloaded."));
|
||||
|
@ -527,8 +526,6 @@ QString makeConflictFileName(const QString &fn, const QDateTime &dt)
|
|||
|
||||
void PropagateDownloadFileQNAM::downloadFinished()
|
||||
{
|
||||
_validator->deleteLater();
|
||||
|
||||
QString fn = _propagator->getFilePath(_item._file);
|
||||
|
||||
// In case of file name clash, report an error
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
|
||||
namespace OCC {
|
||||
|
||||
class TransmissionChecksumValidator;
|
||||
|
||||
class GETFileJob : public AbstractNetworkJob {
|
||||
Q_OBJECT
|
||||
QFile* _device;
|
||||
|
@ -119,8 +117,6 @@ private:
|
|||
// Utility::StopWatch _stopWatch;
|
||||
QPointer<GETFileJob> _job;
|
||||
QFile _tmpFile;
|
||||
TransmissionChecksumValidator *_validator;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -211,15 +211,13 @@ void PropagateUploadFileQNAM::start()
|
|||
// do whatever is needed to add a checksum to the http upload request.
|
||||
// in any case, the validator will emit signal startUpload to let the flow
|
||||
// continue in slotStartUpload here.
|
||||
_validator = new TransmissionChecksumValidator(filePath);
|
||||
connect(_validator, SIGNAL(validated()), this, SLOT(slotStartUpload()));
|
||||
_validator->uploadValidation( &_item );
|
||||
TransmissionChecksumValidator *validator = new TransmissionChecksumValidator(filePath, this);
|
||||
connect(validator, SIGNAL(validated()), this, SLOT(slotStartUpload()));
|
||||
validator->uploadValidation( &_item );
|
||||
}
|
||||
|
||||
void PropagateUploadFileQNAM::slotStartUpload()
|
||||
{
|
||||
_validator->deleteLater();
|
||||
|
||||
const QString fullFilePath(_propagator->getFilePath(_item._file));
|
||||
|
||||
if (!FileSystem::fileExists(fullFilePath)) {
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
namespace OCC {
|
||||
class BandwidthManager;
|
||||
class TransmissionChecksumValidator;
|
||||
|
||||
class UploadDevice : public QIODevice {
|
||||
Q_OBJECT
|
||||
|
@ -172,8 +171,6 @@ private:
|
|||
// measure the performance of checksum calc and upload
|
||||
Utility::StopWatch _stopWatch;
|
||||
|
||||
TransmissionChecksumValidator *_validator;
|
||||
|
||||
public:
|
||||
PropagateUploadFileQNAM(OwncloudPropagator* propagator,const SyncFileItem& item)
|
||||
: PropagateItemJob(propagator, item), _startChunk(0), _currentChunk(0), _chunkCount(0), _transferId(0), _finished(false) {}
|
||||
|
|
Loading…
Reference in a new issue