diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2013-12-03 17:43:01 +0400 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2013-12-03 17:44:04 +0400 |
commit | 09d850bfaaabdb03c47b115ca1b3e90fbb0d1f0d (patch) | |
tree | 08c16d5821e308b5bfbb2761f59b3a17b4ad8944 | |
parent | f0a6047ecf9b1fbeee3802f3a45bb2fa970867dd (diff) |
When the temporary file is the same size as the file we would download, just keep it
Don't download the file if the temporary file is complete.
else, we get error from server: Requested Range not satisfiable
-rw-r--r-- | src/mirall/owncloudpropagator.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mirall/owncloudpropagator.cpp b/src/mirall/owncloudpropagator.cpp index 92b10fb79..238681f9f 100644 --- a/src/mirall/owncloudpropagator.cpp +++ b/src/mirall/owncloudpropagator.cpp @@ -703,11 +703,15 @@ void PropagateDownloadFile::start() ne_add_request_header( req.data(), "Accept-Encoding", "gzip" ); if (tmpFile.size() > 0) { - char brange[64]; - ne_snprintf(brange, sizeof brange, "bytes=%lld-", (long long) tmpFile.size()); - ne_add_request_header(req.data(), "Range", brange); + quint64 done = tmpFile.size(); + if (done == _item._size) { + qDebug() << "File is already complete, no need to download"; + break; + } + QByteArray rangeRequest = "bytes=" + QByteArray::number(done) +'-'; + ne_add_request_header(req.data(), "Range", rangeRequest.constData()); ne_add_request_header(req.data(), "Accept-Ranges", "bytes"); - qDebug("Retry with range %s", brange); + qDebug() << "Retry with range " << rangeRequest; } /* hook called before the content is parsed to set the correct reader, |