bool ok = false;
auto chunkId = name.mid(name.lastIndexOf('/')+1).toUInt(&ok);
if (ok) {
- this->_serverChunks[chunkId] = properties["getcontentlength"].toULongLong();
+ _serverChunks[chunkId] = properties["getcontentlength"].toULongLong();
}
}
++_currentChunk;
}
+ if (_sent > _item->_size) {
+ // Normally this can't happen because the size is xor'ed with the transfer id, and it is
+ // therefore impossible that there is more data on the server than on the file.
+ qWarning() << "Inconsistency while resuming " << _item->_file
+ << ": the size on the server (" << _sent << ") is bigger than the size of the file ("
+ << _item->_size << ")";
+ startNewUpload();
+ return;
+ }
+
qDebug() << "Resuming "<< _item->_file << " from chunk " << _currentChunk << "; sent ="<< _sent;
if (!_serverChunks.isEmpty()) {
return;
quint64 fileSize = _item->_size;
-
+ Q_ASSERT(fileSize >= _sent);
quint64 currentChunkSize = qMin(chunkSize(), fileSize - _sent);
- if (currentChunkSize <= 0) {
+ if (currentChunkSize == 0) {
Q_ASSERT(_jobs.isEmpty()); // There should be no running job anymore
_finished = true;
// Finish with a MOVE
- // QString destination = _propagator->_remoteDir + _item->_file; // FIXME: _remoteDir currently is still using the old webdav path
QString destination = _propagator->account()->url().path()
+ QLatin1String("/remote.php/dav/files/") + _propagator->account()->user()
+ _propagator->_remoteFolder + _item->_file;
return;
}
- bool finished = _sent >= _item->_size;
+ Q_ASSERT(_sent <= _item->_size);
+ bool finished = _sent == _item->_size;
// Check if the file still exists
const QString fullFilePath(_propagator->getFilePath(_item->_file));
_propagator->_anotherSyncNeeded = true;
if( !finished ) {
abortWithError(SyncFileItem::SoftError, tr("Local file changed during sync."));
- // FIXME: the legacy code was retrying for a few seconds.
- // and also checking that after the last chunk, and removed the file in case of INSTRUCTION_NEW
return;
}
}