Skip to content

Commit

Permalink
Move destination header build to own method
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Oct 11, 2023
1 parent e51fba5 commit 230c4eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/libsync/propagateupload.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ private slots:

[[nodiscard]] QUrl chunkUploadFolderUrl() const;
[[nodiscard]] QUrl chunkUrl(const int chunk) const;
[[nodiscard]] QByteArray destinationHeader() const;

void startNewUpload();
void startNextChunk();
Expand Down
14 changes: 9 additions & 5 deletions src/libsync/propagateuploadng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -362,11 +370,7 @@ void PropagateUploadFileNG::startNextChunk()

QMap<QByteArray, QByteArray> 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);
Expand Down

0 comments on commit 230c4eb

Please sign in to comment.