Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
|| _item->_status == SyncFileItem::Conflict) {
_item->_status = SyncFileItem::Restoration;
} else {
_item->_errorString += tr("; Restoration Failed: %1").arg(errorString);
_item->_errorString = tr("%1. Restoration failed: %2", "%1 is the generic error string, the file restoration error (%2) will be appended here").arg(_item->_errorString, errorString);
}
} else {
if (_item->_errorString.isEmpty()) {
Expand Down Expand Up @@ -313,7 +313,7 @@
&& rec.isValid() && rec.isE2eEncrypted();
}

void PropagateItemJob::reportClientStatuses()

Check warning on line 316 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_O&open=AZ0kST4MNWet5u0PD4_O&pullRequest=9692
{
if (_item->_status == SyncFileItem::Status::FileNameClash) {
if (_item->_direction != SyncFileItem::Direction::Up) {
Expand All @@ -324,7 +324,7 @@
} else if (_item->_httpErrorCode != HttpErrorCodeNone && _item->_httpErrorCode != HttpErrorCodeSuccess
&& _item->_httpErrorCode != HttpErrorCodeSuccessCreated && _item->_httpErrorCode != HttpErrorCodeSuccessNoContent) {
if (_item->_direction == SyncFileItem::Up) {
const auto isCodeBadReqOrUnsupportedMediaType =

Check warning on line 327 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_P&open=AZ0kST4MNWet5u0PD4_P&pullRequest=9692
(_item->_httpErrorCode == HttpErrorCodeBadRequest || _item->_httpErrorCode == HttpErrorCodeUnsupportedMediaType);
const auto isExceptionInfoPresent = !_item->_errorExceptionName.isEmpty() && !_item->_errorExceptionMessage.isEmpty();
if (isCodeBadReqOrUnsupportedMediaType && isExceptionInfoPresent && _item->_errorExceptionName.contains(QStringLiteral("UnsupportedMediaType"))
Expand All @@ -344,7 +344,7 @@
PropagateItemJob *OwncloudPropagator::createJob(const SyncFileItemPtr &item)
{
bool deleteExisting = item->_instruction == CSYNC_INSTRUCTION_TYPE_CHANGE;
switch (item->_instruction) {

Check failure on line 347 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a "default" case to this switch statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_Q&open=AZ0kST4MNWet5u0PD4_Q&pullRequest=9692
case CSYNC_INSTRUCTION_REMOVE:
if (item->_direction == SyncFileItem::Down)
return new PropagateLocalRemove(this, item);
Expand Down Expand Up @@ -386,12 +386,12 @@
return new PropagateLocalRename(this, item);
}
case CSYNC_INSTRUCTION_UPDATE_VFS_METADATA:
return new PropagateVfsUpdateMetadataJob(this, item);

Check failure on line 389 in src/libsync/owncloudpropagator.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=AZ0kST4MNWet5u0PD4_R&open=AZ0kST4MNWet5u0PD4_R&pullRequest=9692
case CSYNC_INSTRUCTION_UPDATE_ENCRYPTION_METADATA:
{
const auto rootE2eeFolderPath = item->_file.split('/').first();
const auto rootE2eeFolderPathFullRemotePath = fullRemotePath(rootE2eeFolderPath);

Check warning on line 393 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_S&open=AZ0kST4MNWet5u0PD4_S&pullRequest=9692
return new UpdateMigratedE2eeMetadataJob(this, item, rootE2eeFolderPathFullRemotePath, remotePath());

Check failure on line 394 in src/libsync/owncloudpropagator.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=AZ0kST4MNWet5u0PD4_T&open=AZ0kST4MNWet5u0PD4_T&pullRequest=9692
}
case CSYNC_INSTRUCTION_IGNORE:
case CSYNC_INSTRUCTION_ERROR:
Expand Down Expand Up @@ -451,7 +451,7 @@
if (folderPathSplit.isEmpty()) {
continue;
}
const auto itemRootFolderName = folderPathSplit.first();

Check warning on line 454 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid this unnecessary copy by using a "const" reference.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_U&open=AZ0kST4MNWet5u0PD4_U&pullRequest=9692
if (itemRootFolderName.isEmpty()) {
continue;
}
Expand Down Expand Up @@ -499,7 +499,7 @@
return smallFileSize;
}

void OwncloudPropagator::start(SyncFileItemVector &&items)

Check warning on line 502 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

"std::move" is never called on this rvalue reference argument.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_W&open=AZ0kST4MNWet5u0PD4_W&pullRequest=9692
{
Q_ASSERT(std::is_sorted(items.begin(), items.end()));

Expand All @@ -520,13 +520,13 @@
do {
ref = i->_file.mid(0, index);
names.insert(ref);
index = ref.lastIndexOf(QLatin1Char('/'));

Check warning on line 523 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_N&open=AZ0kST4MNWet5u0PD4_N&pullRequest=9692
} while (index > 0);
}
}
items.erase(std::remove_if(items.begin(), items.end(), [&names](auto i) {
return !names.contains(QStringView { i->_file });
}),

Check warning on line 529 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace with the version of "std::ranges::remove_if" that takes a range.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_X&open=AZ0kST4MNWet5u0PD4_X&pullRequest=9692
items.end());
}

Expand Down Expand Up @@ -562,7 +562,7 @@
// aborted while uploading this directory (which is now removed). We can ignore it.

// increase the number of subjobs that would be there.
if (item->_wantsSpecificActions == SyncFileItem::SynchronizationOptions::MoveToClientTrashBin) {

Check failure on line 565 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_V&open=AZ0kST4MNWet5u0PD4_V&pullRequest=9692
qCInfo(lcPropagator()) << "special handling for delete/new conflict";
delDirJob->willDeleteItemToClientTrashBin(item);
}
Expand Down Expand Up @@ -696,7 +696,7 @@
(item->_instruction == CSYNC_INSTRUCTION_NEW || item->_instruction == CSYNC_INSTRUCTION_SYNC);
const auto isVirtualFile = item->_type == ItemTypeVirtualFile;
const auto isEncrypted = item->_e2eEncryptionStatus != SyncFileItem::EncryptionStatus::NotEncrypted;
const auto shouldAddBulkPropagateDownloadItem = isDownload && isVirtualFile && isVfsCfApi && !isEncrypted;

Check warning on line 699 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

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

if (shouldAddBulkPropagateDownloadItem) {
addBulkPropagateDownloadItem(item, directories);
Expand All @@ -715,17 +715,17 @@
void OwncloudPropagator::addBulkPropagateDownloadItem(const SyncFileItemPtr &item, QStack<QPair<QString, PropagateDirectory *>> &directories)
{
auto bulkPropagatorDownloadJob = static_cast<BulkPropagatorDownloadJob*>(nullptr);
const auto foundBulkPrpagatorDownloadJobIt = std::find_if(std::cbegin(directories.top().second->_subJobs._jobsToDo),
std::cend(directories.top().second->_subJobs._jobsToDo),
[](PropagatorJob *job)

Check warning on line 720 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_b&open=AZ0kST4MNWet5u0PD4_b&pullRequest=9692
{
const auto bulkDownloadJob = qobject_cast<BulkPropagatorDownloadJob *>(job);
return bulkDownloadJob != nullptr;
}
);

Check warning on line 725 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace with the version of "std::ranges::find_if" that takes a range.

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

if (foundBulkPrpagatorDownloadJobIt == std::cend(directories.top().second->_subJobs._jobsToDo)) {

Check warning on line 727 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "foundBulkPrpagatorDownloadJobIt" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_Z&open=AZ0kST4MNWet5u0PD4_Z&pullRequest=9692
bulkPropagatorDownloadJob = new BulkPropagatorDownloadJob(this, directories.top().second);

Check failure on line 728 in src/libsync/owncloudpropagator.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=AZ0kST4MNWet5u0PD4_c&open=AZ0kST4MNWet5u0PD4_c&pullRequest=9692
directories.top().second->appendJob(bulkPropagatorDownloadJob);
} else {
bulkPropagatorDownloadJob = qobject_cast<BulkPropagatorDownloadJob *>(*foundBulkPrpagatorDownloadJobIt);
Expand All @@ -733,7 +733,7 @@
bulkPropagatorDownloadJob->addDownloadItem(item);
}

void OwncloudPropagator::processE2eeMetadataMigration(const SyncFileItemPtr &item, QStack<QPair<QString, PropagateDirectory *>> &directories)

Check failure on line 736 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 32 to the 25 allowed.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_d&open=AZ0kST4MNWet5u0PD4_d&pullRequest=9692
{
if (item->_e2eEncryptionServerCapability >= EncryptionStatusEnums::ItemEncryptionStatus::EncryptedMigratedV2_0) {
// migrating to v2.0+
Expand All @@ -741,7 +741,7 @@
const auto rootE2eeFolderPathWithSlash = QString(rootE2eeFolderPath + "/");

QPair<QString, PropagateDirectory *> foundDirectory = {QString{}, nullptr};
for (auto it = std::rbegin(directories); it != std::rend(directories); ++it) {

Check warning on line 744 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this loop so that it is less error-prone.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_f&open=AZ0kST4MNWet5u0PD4_f&pullRequest=9692
if (it->first == rootE2eeFolderPathWithSlash) {
foundDirectory = *it;
break;
Expand All @@ -754,8 +754,8 @@
if (foundDirectory.second) {
topLevelitem = foundDirectory.second->_item;
if (!foundDirectory.second->_subJobs._jobsToDo.isEmpty()) {
for (const auto jobToDo : std::as_const(foundDirectory.second->_subJobs._jobsToDo)) {

Check failure on line 757 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_e&open=AZ0kST4MNWet5u0PD4_e&pullRequest=9692
if (const auto foundExistingUpdateMigratedE2eeMetadataJob = qobject_cast<UpdateMigratedE2eeMetadataJob *>(jobToDo)) {

Check warning on line 758 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_g&open=AZ0kST4MNWet5u0PD4_g&pullRequest=9692
existingUpdateJob = foundExistingUpdateMigratedE2eeMetadataJob;
break;
}
Expand All @@ -766,8 +766,8 @@
if (!existingUpdateJob) {
// we will need to update topLevelitem encryption status so it gets written to database
const auto currentDirJob = directories.top().second;
const auto rootE2eeFolderPathFullRemotePath = fullRemotePath(rootE2eeFolderPath);

Check warning on line 769 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_h&open=AZ0kST4MNWet5u0PD4_h&pullRequest=9692
const auto updateMetadataJob = new UpdateMigratedE2eeMetadataJob(this, topLevelitem, rootE2eeFolderPathFullRemotePath, remotePath());

Check failure on line 770 in src/libsync/owncloudpropagator.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=AZ0kST4MNWet5u0PD4_i&open=AZ0kST4MNWet5u0PD4_i&pullRequest=9692
if (item != topLevelitem) {
updateMetadataJob->addSubJobItem(item->_encryptedFileName, item);
}
Expand Down Expand Up @@ -1092,16 +1092,16 @@
return OCC::adjustRenamedPath(_renamedDirectories, original);
}

Result<Vfs::ConvertToPlaceholderResult, QString> OwncloudPropagator::updateMetadata(const SyncFileItem &item, Vfs::UpdateMetadataTypes updateType)

Check warning on line 1095 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "updateType" of type "class QFlags<enum OCC::Vfs::UpdateMetadataType>" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_j&open=AZ0kST4MNWet5u0PD4_j&pullRequest=9692
{
return OwncloudPropagator::staticUpdateMetadata(item, _localDir, syncOptions()._vfs.data(), _journal, updateType);
}

Result<Vfs::ConvertToPlaceholderResult, QString> OwncloudPropagator::staticUpdateMetadata(const SyncFileItem &item,
const QString localDir,
Vfs *vfs,

Check warning on line 1102 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "vfs" of type "class OCC::Vfs *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_k&open=AZ0kST4MNWet5u0PD4_k&pullRequest=9692
SyncJournalDb *const journal,
Vfs::UpdateMetadataTypes updateType)

Check warning on line 1104 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "updateType" of type "class QFlags<enum OCC::Vfs::UpdateMetadataType>" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_l&open=AZ0kST4MNWet5u0PD4_l&pullRequest=9692
{
const QString fsPath = localDir + item.destination();
auto record = item.toSyncJournalFileRecordWithInode(fsPath);
Expand Down Expand Up @@ -1255,7 +1255,7 @@
}

// Ask all the running composite jobs if they have something new to schedule.
for (auto runningJob : std::as_const(_runningJobs)) {

Check warning on line 1258 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "runningJob" of type "class OCC::PropagatorJob *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_m&open=AZ0kST4MNWet5u0PD4_m&pullRequest=9692
ASSERT(runningJob->_state == Running);

if (possiblyRunNextJob(runningJob)) {
Expand Down Expand Up @@ -1382,9 +1382,9 @@
connect(&_subJobs, &PropagatorJob::finished, this, &PropagateDirectory::slotSubJobsFinished);
}

void PropagateDirectory::willDeleteItemToClientTrashBin(const SyncFileItemPtr &item)

Check warning on line 1385 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_n&open=AZ0kST4MNWet5u0PD4_n&pullRequest=9692
{
auto deleteFolderJob = dynamic_cast<PropagateLocalRemove*>(_firstJob.get());

Check warning on line 1387 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "deleteFolderJob" of type "class OCC::PropagateLocalRemove *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_o&open=AZ0kST4MNWet5u0PD4_o&pullRequest=9692
if (!deleteFolderJob) {
return;
}
Expand Down Expand Up @@ -1509,11 +1509,11 @@
if (!_item->_remotePerm.isNull() &&
!_item->_remotePerm.hasPermissionsForReadWrite()) {
try {
if (const auto fileName = propagator()->fullLocalPath(_item->_file); FileSystem::fileExists(fileName)) {

Check failure on line 1512 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_p&open=AZ0kST4MNWet5u0PD4_p&pullRequest=9692
FileSystem::setFolderPermissions(fileName, FileSystem::FolderPermissions::ReadOnly);
Q_EMIT propagator()->touchedFile(fileName);
}
if (!_item->_renameTarget.isEmpty() && FileSystem::fileExists(propagator()->fullLocalPath(_item->_renameTarget))) {

Check failure on line 1516 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_q&open=AZ0kST4MNWet5u0PD4_q&pullRequest=9692
const auto fileName = propagator()->fullLocalPath(_item->_renameTarget);
FileSystem::setFolderPermissions(fileName, FileSystem::FolderPermissions::ReadOnly);
Q_EMIT propagator()->touchedFile(fileName);
Expand All @@ -1531,7 +1531,7 @@
_item->_status = SyncFileItem::NormalError;
_item->_errorString = tr("The folder %1 cannot be made read-only: %2").arg(_item->_file, e.what());
}
catch (...)

Check warning on line 1534 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

"catch" a specific exception type.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_u&open=AZ0kST4MNWet5u0PD4_u&pullRequest=9692
{
qCWarning(lcDirectory) << "exception when checking parent folder access rights";
_item->_status = SyncFileItem::NormalError;
Expand All @@ -1547,10 +1547,10 @@
qCDebug(lcDirectory) << fileName << "applied new permissions" << static_cast<int>(std::filesystem::status(fileName.toStdWString()).permissions());
};

if (const auto fileName = propagator()->fullLocalPath(_item->_file); FileSystem::fileExists(fileName)) {

Check failure on line 1550 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_r&open=AZ0kST4MNWet5u0PD4_r&pullRequest=9692
permissionsChangeHelper(fileName);
}
if (const auto fileName = propagator()->fullLocalPath(_item->_renameTarget); !_item->_renameTarget.isEmpty() && FileSystem::fileExists(fileName)) {

Check failure on line 1553 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_s&open=AZ0kST4MNWet5u0PD4_s&pullRequest=9692
permissionsChangeHelper(fileName);
}
}
Expand All @@ -1566,7 +1566,7 @@
_item->_status = SyncFileItem::NormalError;
_item->_errorString = tr("The folder %1 cannot be made read-only: %2").arg("", e.what());
}
catch (...)

Check warning on line 1569 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

"catch" a specific exception type.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_v&open=AZ0kST4MNWet5u0PD4_v&pullRequest=9692
{
qCWarning(lcDirectory) << "exception when checking parent folder access rights";
_item->_status = SyncFileItem::NormalError;
Expand All @@ -1575,7 +1575,7 @@
}
if (!_item->_isAnyCaseClashChild && !_item->_isAnyInvalidCharChild) {
const auto result = propagator()->updateMetadata(*_item);
if (!result) {

Check failure on line 1578 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_t&open=AZ0kST4MNWet5u0PD4_t&pullRequest=9692
status = _item->_status = SyncFileItem::FatalError;
_item->_errorString = tr("Error updating metadata: %1").arg(result.error());
qCWarning(lcDirectory) << "Error writing to the database for file" << _item->_file << "with" << result.error();
Expand Down Expand Up @@ -1640,7 +1640,7 @@

void PropagateRootDirectory::appendDirDeletionJob(PropagatorJob *job)
{
if (auto directoryJob = qobject_cast<PropagateDirectory*>(job)) {

Check warning on line 1643 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "directoryJob" of type "class OCC::PropagateDirectory *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_w&open=AZ0kST4MNWet5u0PD4_w&pullRequest=9692
qCDebug(lcRootDirectory) << "new folder deletion job" << directoryJob->_item->_file;
}
_dirDeletionJobs.appendJob(job);
Expand Down Expand Up @@ -1790,7 +1790,7 @@
return _remoteFolder + tmp_file_name;
}

QString OwncloudPropagator::fulllRemotePathToPathInSyncJournalDb(const QString &fullRemotePath) const

Check warning on line 1793 in src/libsync/owncloudpropagator.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0kST4MNWet5u0PD4_x&open=AZ0kST4MNWet5u0PD4_x&pullRequest=9692
{
auto result = _remoteFolder != QStringLiteral("/") ? fullRemotePath.mid(_remoteFolder.size()) : fullRemotePath;
if (result.startsWith("/")) {
Expand Down