From 2b9b1822045240717b53471d00b0ecc22ef762ec Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 11 Oct 2023 16:19:30 +0800 Subject: [PATCH] Move destination header build to own method Signed-off-by: Claudio Cambra --- src/libsync/propagateupload.h | 1 + src/libsync/propagateuploadng.cpp | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libsync/propagateupload.h b/src/libsync/propagateupload.h index e12e4500a..33db43f29 100644 --- a/src/libsync/propagateupload.h +++ b/src/libsync/propagateupload.h @@ -410,6 +410,7 @@ private: [[nodiscard]] QUrl chunkUploadFolderUrl() const; [[nodiscard]] QUrl chunkUrl(const int chunk) const; + [[nodiscard]] QByteArray destinationHeader() const; void startNewUpload(); void startNextChunk(); diff --git a/src/libsync/propagateuploadng.cpp b/src/libsync/propagateuploadng.cpp index 437fd7adc..e477cb830 100644 --- a/src/libsync/propagateuploadng.cpp +++ b/src/libsync/propagateuploadng.cpp @@ -85,6 +85,14 @@ QUrl PropagateUploadFileNG::chunkUrl(const int chunk) const */ +QByteArray PropagateUploadFileNG::destinationHeader() const +{ + const auto davUrl = Utility::trailingSlashPath(propagator()->account()->davUrl().toString()); + const auto remotePath = Utility::noLeadingSlashPath(propagator()->fullRemotePath(_fileToUpload._file)); + const auto destination = QString(davUrl + remotePath); + return destination.toUtf8(); +} + void PropagateUploadFileNG::doStartUpload() { propagator()->_activeJobList.append(this); @@ -362,11 +370,7 @@ void PropagateUploadFileNG::startNextChunk() QMap headers; headers["OC-Chunk-Offset"] = QByteArray::number(_sent); - - const auto davUrl = Utility::trailingSlashPath(propagator()->account()->davUrl().toString()); - const auto remotePath = Utility::noLeadingSlashPath(propagator()->fullRemotePath(_fileToUpload._file)); - const auto destination = QString(davUrl + remotePath); - headers["Destination"] = destination.toUtf8(); + headers["Destination"] = destinationHeader(); _sent += _currentChunkSize; const auto url = chunkUrl(_currentChunk);