Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/libsync/propagateuploadng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "config.h"

Check failure on line 7 in src/libsync/propagateuploadng.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/propagateuploadng.cpp:7:10 [clang-diagnostic-error]

'config.h' file not found
#include "propagateupload.h"
#include "owncloudpropagator_p.h"
#include "networkjobs.h"
Expand All @@ -25,6 +25,8 @@
#include <cmath>
#include <cstring>

using namespace Qt::StringLiterals;

namespace OCC {

constexpr auto relativeUploadsPath = "remote.php/dav/uploads/";
Expand Down Expand Up @@ -80,9 +82,9 @@
QByteArray PropagateUploadFileNG::destinationHeader() const
{
const auto davUrl = Utility::trailingSlashPath(propagator()->account()->davUrl().toString());
const auto remotePath = Utility::noLeadingSlashPath(propagator()->fullRemotePath(_fileToUpload._file));
const auto remotePath = QUrl::toPercentEncoding(Utility::noLeadingSlashPath(propagator()->fullRemotePath(_fileToUpload._file)), "/"_ba);
const auto destination = QString(davUrl + remotePath);
return QUrl::toPercentEncoding(destination, "/");
return destination.toUtf8();
}

void PropagateUploadFileNG::doStartUpload()
Expand All @@ -97,7 +99,7 @@
if (progressInfo._valid && progressInfo.isChunked() && progressInfo._modtime == _item->_modtime && progressInfo._size == _item->_size) {
_transferId = progressInfo._transferid;

const auto job = new LsColJob(propagator()->account(), chunkUploadFolderUrl());

Check failure on line 102 in src/libsync/propagateuploadng.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZzXRP25JBdaFffnDtFJ&open=AZzXRP25JBdaFffnDtFJ&pullRequest=9588
_jobs.append(job);
job->setProperties(QList<QByteArray>() << "resourcetype"
<< "getcontentlength");
Expand All @@ -113,7 +115,7 @@
// The upload info is stale. remove the stale chunks on the server
_transferId = progressInfo._transferid;
// Fire and forget. Any error will be ignored.
(new DeleteJob(propagator()->account(), chunkUploadFolderUrl(), {}, this))->start();

Check failure on line 118 in src/libsync/propagateuploadng.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZzXRP25JBdaFffnDtFK&open=AZzXRP25JBdaFffnDtFK&pullRequest=9588
// startNewUpload will reset the _transferId and the UploadInfo in the db.
}

Expand Down Expand Up @@ -160,7 +162,7 @@

// Wipe the old chunking data.
// Fire and forget. Any error will be ignored.
(new DeleteJob(propagator()->account(), chunkUploadFolderUrl(), {}, this))->start();

Check failure on line 165 in src/libsync/propagateuploadng.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZzXRP25JBdaFffnDtFM&open=AZzXRP25JBdaFffnDtFM&pullRequest=9588

propagator()->_activeJobList.append(this);
startNewUpload();
Expand All @@ -178,7 +180,7 @@
// we should remove the later chunks. Otherwise when we do dynamic chunk sizing, we may end up
// with corruptions if there are too many chunks, or if we abort and there are still stale chunks.
for (const auto &serverChunk : std::as_const(_serverChunks)) {
auto job = new DeleteJob(propagator()->account(), Utility::concatUrlPath(chunkUploadFolderUrl(), serverChunk.originalName), {}, this);

Check warning on line 183 in src/libsync/propagateuploadng.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Declaration shadows a local variable "job" in the outer scope.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZzXRP25JBdaFffnDtFL&open=AZzXRP25JBdaFffnDtFL&pullRequest=9588

Check failure on line 183 in src/libsync/propagateuploadng.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZzXRP25JBdaFffnDtFO&open=AZzXRP25JBdaFffnDtFO&pullRequest=9588

Check warning on line 183 in src/libsync/propagateuploadng.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "job" of type "class OCC::DeleteJob *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZzXRP25JBdaFffnDtFN&open=AZzXRP25JBdaFffnDtFN&pullRequest=9588
QObject::connect(job, &DeleteJob::finishedSignal, this, &PropagateUploadFileNG::slotDeleteJobFinished);
_jobs.append(job);
job->start();
Expand Down Expand Up @@ -354,7 +356,7 @@

const auto fileName = _fileToUpload._path;
auto device = std::make_unique<UploadDevice>(fileName, _sent, _currentChunkSize, &propagator()->_bandwidthManager);
if (auto isLocked = FileSystem::isFileLocked(fileName, FileSystem::LockMode::SharedRead); isLocked || !device->open(QIODevice::ReadOnly)) {

Check warning on line 359 in src/libsync/propagateuploadng.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "isLocked" of type "_Bool" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZzdtX6fqn45uAgxgHJR&open=AZzdtX6fqn45uAgxgHJR&pullRequest=9588
qCWarning(lcPropagateUploadNG) << "Could not prepare upload device: " << device->errorString();

// If the file is currently locked, we want to retry the sync
Expand Down Expand Up @@ -410,7 +412,7 @@
_item->_httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
_item->_requestId = job->requestId();
commonErrorHandling(job);
const auto exceptionParsed = getExceptionFromReply(job->reply());

Check warning on line 415 in src/libsync/propagateuploadng.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this declaration by a structured binding declaration.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZzXRP25JBdaFffnDtFP&open=AZzXRP25JBdaFffnDtFP&pullRequest=9588
_item->_errorExceptionName = exceptionParsed.first;
_item->_errorExceptionMessage = exceptionParsed.second;
return;
Expand Down Expand Up @@ -498,7 +500,7 @@

if (err != QNetworkReply::NoError) {
commonErrorHandling(job);
const auto exceptionParsed = getExceptionFromReply(job->reply());

Check warning on line 503 in src/libsync/propagateuploadng.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this declaration by a structured binding declaration.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZzXRP25JBdaFffnDtFR&open=AZzXRP25JBdaFffnDtFR&pullRequest=9588
_item->_errorExceptionName = exceptionParsed.first;
_item->_errorExceptionMessage = exceptionParsed.second;
return;
Expand Down Expand Up @@ -534,7 +536,7 @@
}

if (SyncJournalFileRecord oldRecord; propagator()->_journal->getFileRecord(_item->destination(), &oldRecord) && oldRecord.isValid()) {
if (oldRecord._etag != _item->_etag) {

Check warning on line 539 in src/libsync/propagateuploadng.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this "if" statement with the enclosing one.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZzXRP25JBdaFffnDtFQ&open=AZzXRP25JBdaFffnDtFQ&pullRequest=9588
_item->updateLockStateFromDbRecord(oldRecord);
}
}
Expand Down
1 change: 1 addition & 0 deletions test/testchunkingng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ private slots:
QVERIFY(destinationHeader.contains("SQ-0.5%25BF-150"));
QVERIFY(destinationHeader.contains("/A/SQ-0.5%25BF-150/"));
QVERIFY(!destinationHeader.contains("%2F"));
QVERIFY(destinationHeader.startsWith("http://"));
}

// Test resuming when there's a confusing chunk added
Expand Down
Loading