Move destination header build to own method

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-10-11 16:19:30 +08:00 committed by Matthieu Gallien
parent a29af562de
commit 2b9b182204
2 changed files with 10 additions and 5 deletions

View file

@ -410,6 +410,7 @@ private:
[[nodiscard]] QUrl chunkUploadFolderUrl() const;
[[nodiscard]] QUrl chunkUrl(const int chunk) const;
[[nodiscard]] QByteArray destinationHeader() const;
void startNewUpload();
void startNextChunk();

View file

@ -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<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);