[Pkg-owncloud-commits] [owncloud-client] 300/333: Propagator: Fix chunking
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu Apr 17 23:17:07 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 0f7d448058ea78f2dbc41f7e72762d6c1d617039
Author: Markus Goetz <markus at woboq.com>
Date: Fri Apr 4 15:41:35 2014 +0200
Propagator: Fix chunking
---
src/mirall/propagator_qnam.cpp | 35 +++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index 13d9935..951e3a7 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -110,11 +110,15 @@ void PropagateUploadFileQNAM::start()
}
struct ChunkDevice : QIODevice {
+ Q_OBJECT
+public:
QIODevice *_file;
qint64 _read;
+ qint64 _size;
+ qint64 _start;
- ChunkDevice(QIODevice *file, qint64 start)
- : QIODevice(file), _file(file), _read(0) {
+ ChunkDevice(QIODevice *file, qint64 start, qint64 size)
+ : QIODevice(file), _file(file), _read(0), _size(size), _start(start) {
_file->seek(start);
}
@@ -135,7 +139,21 @@ struct ChunkDevice : QIODevice {
virtual bool atEnd() const {
return _read >= chunkSize() || _file->atEnd();
}
+
+ virtual qint64 size() const{
+ return _size;
+ }
+
+ // random access, we can seek
+ virtual bool isSequential() const{
+ return false;
+ }
+
+ virtual bool seek ( qint64 pos ) {
+ return _file->seek(pos + _start);
+ }
};
+#include "propagator_qnam.moc"
void PropagateUploadFileQNAM::startNextChunk()
{
@@ -175,10 +193,15 @@ void PropagateUploadFileQNAM::startNextChunk()
uint transid = _transferId ^ chunkSize();
path += QString("-chunking-%1-%2-%3").arg(transid).arg(_chunkCount).arg(sendingChunk);
headers["OC-Chunked"] = "1";
- device = new ChunkDevice(_file, chunkSize() * sendingChunk);
+ int currentChunkSize = chunkSize();
+ if (sendingChunk == _chunkCount - 1) // last chunk
+ currentChunkSize = (fileSize % chunkSize());
+ device = new ChunkDevice(_file, chunkSize() * sendingChunk, currentChunkSize);
} else {
device = _file;
}
+ if (!device->isOpen())
+ device->open(QIODevice::ReadOnly);
_job = new PUTFileJob(AccountManager::instance()->account(), _propagator->_remoteFolder + path, device, headers);
connect(_job, SIGNAL(finishedSignal()), this, SLOT(slotPutFinished()));
@@ -191,7 +214,11 @@ void PropagateUploadFileQNAM::slotPutFinished()
PUTFileJob *job = qobject_cast<PUTFileJob *>(sender());
Q_ASSERT(job);
- qDebug() << Q_FUNC_INFO << job->reply()->request().url() << "FINISHED WITH STATUS" << job->reply()->error() << job->reply()->errorString();
+ qDebug() << Q_FUNC_INFO << job->reply()->request().url() << "FINISHED WITH STATUS"
+ << job->reply()->error()
+ << (job->reply()->error() == QNetworkReply::NoError ? QLatin1String("") : job->reply()->errorString())
+ << job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute)
+ << job->reply()->attribute(QNetworkRequest::HttpReasonPhraseAttribute);
QNetworkReply::NetworkError err = job->reply()->error();
if (err != QNetworkReply::NoError) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list