diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp index f869e30e6f..589f6b8246 100644 --- a/src/mirall/propagator_qnam.cpp +++ b/src/mirall/propagator_qnam.cpp @@ -200,7 +200,7 @@ void PropagateUploadFileQNAM::startNextChunk() } QString path = _item._file; - QIODevice *device; + QIODevice *device = 0; if (_chunkCount > 1) { int sendingChunk = (_currentChunk + _startChunk) % _chunkCount; // XOR with chunk size to make sure everything goes well if chunk size change between runs @@ -218,14 +218,25 @@ void PropagateUploadFileQNAM::startNextChunk() } else { device = _file; } - if (!device->isOpen()) - device->open(QIODevice::ReadOnly); - _job = new PUTFileJob(AccountManager::instance()->account(), _propagator->_remoteFolder + path, device, headers); - _job->setTimeout(_propagator->httpTimeout() * 1000); - connect(_job, SIGNAL(finishedSignal()), this, SLOT(slotPutFinished())); - connect(_job, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(slotUploadProgress(qint64,qint64))); - _job->start(); + bool isOpen = true; + if (!device->isOpen()) { + isOpen = device->open(QIODevice::ReadOnly); + } + + if( isOpen ) { + _job = new PUTFileJob(AccountManager::instance()->account(), _propagator->_remoteFolder + path, device, headers); + _job->setTimeout(_propagator->httpTimeout() * 1000); + connect(_job, SIGNAL(finishedSignal()), this, SLOT(slotPutFinished())); + connect(_job, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(slotUploadProgress(qint64,qint64))); + _job->start(); + } else { + delete device; + + qDebug() << "ERR: Could not open upload file: " << device->errorString(); + done( SyncFileItem::NormalError, device->errorString() ); + return; + } } void PropagateUploadFileQNAM::slotPutFinished()