mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 13:05:51 +03:00
Enable the bugprone-branch-clone clang-tidy check
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
parent
4cb9bec23a
commit
c8ea848596
9 changed files with 34 additions and 45 deletions
|
@ -1,5 +1,6 @@
|
|||
Checks: '-*,
|
||||
bugprone-argument-comment,
|
||||
bugprone-branch-clone,
|
||||
cppcoreguidelines-init-variables,
|
||||
misc-*,
|
||||
-misc-non-private-member-variables-in-classes,
|
||||
|
|
|
@ -188,11 +188,12 @@ static void _csync_merge_algorithm_visitor(csync_file_stat_t *cur, CSYNC * ctx)
|
|||
}();
|
||||
auto curParent = our_tree->findFile(curParentPath);
|
||||
|
||||
if(!other) {
|
||||
// Stick with the NEW
|
||||
return;
|
||||
} else if (!other->e2eMangledName.isEmpty() || (curParent && curParent->isE2eEncrypted)) {
|
||||
// Stick with the NEW as well, we want to always issue delete + upload in such cases
|
||||
if (!other
|
||||
|| !other->e2eMangledName.isEmpty()
|
||||
|| (curParent && curParent->isE2eEncrypted)) {
|
||||
// Stick with the NEW since there's no "other" file
|
||||
// or if there's an "other" file it involves E2EE and
|
||||
// we want to always issue delete + upload in such cases
|
||||
return;
|
||||
} else if (other->instruction == CSYNC_INSTRUCTION_RENAME) {
|
||||
// Some other EVAL_RENAME already claimed other.
|
||||
|
|
|
@ -250,9 +250,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
|
|||
if (f->syncPaused()) {
|
||||
return theme->folderDisabledIcon();
|
||||
} else {
|
||||
if (status == SyncResult::SyncPrepare) {
|
||||
return theme->syncStateIcon(SyncResult::SyncRunning);
|
||||
} else if (status == SyncResult::Undefined) {
|
||||
if (status == SyncResult::SyncPrepare || status == SyncResult::Undefined) {
|
||||
return theme->syncStateIcon(SyncResult::SyncRunning);
|
||||
} else {
|
||||
// The "Problem" *result* just means some files weren't
|
||||
|
@ -1072,7 +1070,7 @@ void FolderStatusModel::slotFolderSyncStateChange(Folder *f)
|
|||
auto &pi = _folders[folderIndex]._progress;
|
||||
|
||||
SyncResult::Status state = f->syncResult().status();
|
||||
if (!f->canSync()) {
|
||||
if (!f->canSync() || state == SyncResult::Problem || state == SyncResult::Success || state == SyncResult::Error) {
|
||||
// Reset progress info.
|
||||
pi = SubFolderInfo::Progress();
|
||||
} else if (state == SyncResult::NotYetStarted) {
|
||||
|
@ -1093,11 +1091,6 @@ void FolderStatusModel::slotFolderSyncStateChange(Folder *f)
|
|||
} else if (state == SyncResult::SyncPrepare) {
|
||||
pi = SubFolderInfo::Progress();
|
||||
pi._overallSyncString = tr("Preparing to sync …");
|
||||
} else if (state == SyncResult::Problem || state == SyncResult::Success) {
|
||||
// Reset the progress info after a sync.
|
||||
pi = SubFolderInfo::Progress();
|
||||
} else if (state == SyncResult::Error) {
|
||||
pi = SubFolderInfo::Progress();
|
||||
}
|
||||
|
||||
// update the icon etc. now
|
||||
|
|
|
@ -413,14 +413,17 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo &
|
|||
{
|
||||
Q_UNUSED(folder);
|
||||
|
||||
// FIXME: Lots of messages computed for nothing in this method, needs revisiting
|
||||
if (progress.status() == ProgressInfo::Discovery) {
|
||||
#if 0
|
||||
if (!progress._currentDiscoveredRemoteFolder.isEmpty()) {
|
||||
//_actionStatus->setText(tr("Checking for changes in remote '%1'")
|
||||
//.arg(progress._currentDiscoveredRemoteFolder));
|
||||
_actionStatus->setText(tr("Checking for changes in remote '%1'")
|
||||
.arg(progress._currentDiscoveredRemoteFolder));
|
||||
} else if (!progress._currentDiscoveredLocalFolder.isEmpty()) {
|
||||
//_actionStatus->setText(tr("Checking for changes in local '%1'")
|
||||
//.arg(progress._currentDiscoveredLocalFolder));
|
||||
_actionStatus->setText(tr("Checking for changes in local '%1'")
|
||||
.arg(progress._currentDiscoveredLocalFolder));
|
||||
}
|
||||
#endif
|
||||
} else if (progress.status() == ProgressInfo::Done) {
|
||||
QTimer::singleShot(2000, this, &ownCloudGui::slotComputeOverallSyncStatus);
|
||||
}
|
||||
|
|
|
@ -159,12 +159,11 @@ void DiscoveryJob::update_job_update_callback(bool local,
|
|||
auto *updateJob = static_cast<DiscoveryJob *>(userdata);
|
||||
if (updateJob) {
|
||||
// Don't wanna overload the UI
|
||||
if (!updateJob->_lastUpdateProgressCallbackCall.isValid()) {
|
||||
updateJob->_lastUpdateProgressCallbackCall.start(); // first call
|
||||
} else if (updateJob->_lastUpdateProgressCallbackCall.elapsed() < 200) {
|
||||
return;
|
||||
} else {
|
||||
if (!updateJob->_lastUpdateProgressCallbackCall.isValid()
|
||||
|| updateJob->_lastUpdateProgressCallbackCall.elapsed() >= 200) {
|
||||
updateJob->_lastUpdateProgressCallbackCall.start();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray pPath(dirUrl);
|
||||
|
|
|
@ -385,11 +385,8 @@ bool LsColJob::finished()
|
|||
// XML parse error
|
||||
emit finishedWithError(reply());
|
||||
}
|
||||
} else if (httpCode == 207) {
|
||||
// wrong content type
|
||||
emit finishedWithError(reply());
|
||||
} else {
|
||||
// wrong HTTP code or any other network error
|
||||
// wrong content type, wrong HTTP code or any other network error
|
||||
emit finishedWithError(reply());
|
||||
}
|
||||
|
||||
|
|
|
@ -404,24 +404,21 @@ void OwncloudPropagator::start(const SyncFileItemVector &items,
|
|||
// this is an item in a directory which is going to be removed.
|
||||
auto *delDirJob = qobject_cast<PropagateDirectory *>(directoriesToRemove.first());
|
||||
|
||||
if (item->_instruction == CSYNC_INSTRUCTION_REMOVE) {
|
||||
// already taken care of. (by the removal of the parent directory)
|
||||
const auto isNewDirectory = item->isDirectory() &&
|
||||
(item->_instruction == CSYNC_INSTRUCTION_NEW || item->_instruction == CSYNC_INSTRUCTION_TYPE_CHANGE);
|
||||
|
||||
if (item->_instruction == CSYNC_INSTRUCTION_REMOVE || isNewDirectory) {
|
||||
// If it is a remove it is already taken care of by the removal of the parent directory
|
||||
|
||||
// If it is a new directory then it is inside a deleted directory... That can happen if
|
||||
// the directory etag was not fetched properly on the previous sync because the sync was
|
||||
// aborted while uploading this directory (which is now removed). We can ignore it.
|
||||
|
||||
// increase the number of subjobs that would be there.
|
||||
if (delDirJob) {
|
||||
delDirJob->increaseAffectedCount();
|
||||
}
|
||||
continue;
|
||||
} else if (item->isDirectory()
|
||||
&& (item->_instruction == CSYNC_INSTRUCTION_NEW
|
||||
|| item->_instruction == CSYNC_INSTRUCTION_TYPE_CHANGE)) {
|
||||
// create a new directory within a deleted directory? That can happen if the directory
|
||||
// etag was not fetched properly on the previous sync because the sync was aborted
|
||||
// while uploading this directory (which is now removed). We can ignore it.
|
||||
if (delDirJob) {
|
||||
delDirJob->increaseAffectedCount();
|
||||
}
|
||||
continue;
|
||||
} else if (item->_instruction == CSYNC_INSTRUCTION_IGNORE) {
|
||||
continue;
|
||||
} else if (item->_instruction == CSYNC_INSTRUCTION_RENAME) {
|
||||
|
|
|
@ -74,7 +74,6 @@ QString Progress::asActionString(const SyncFileItem &item)
|
|||
case CSYNC_INSTRUCTION_IGNORE:
|
||||
return QCoreApplication::translate("progress", "ignoring");
|
||||
case CSYNC_INSTRUCTION_STAT_ERROR:
|
||||
return QCoreApplication::translate("progress", "error");
|
||||
case CSYNC_INSTRUCTION_ERROR:
|
||||
return QCoreApplication::translate("progress", "error");
|
||||
case CSYNC_INSTRUCTION_UPDATE_METADATA:
|
||||
|
|
|
@ -1567,17 +1567,17 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems)
|
|||
const auto filePerms = getPermissions((*it)->_file);
|
||||
|
||||
//true when it is just a rename in the same directory. (not a move)
|
||||
bool isRename = (*it)->_file.startsWith(parentDir) && (*it)->_file.lastIndexOf('/') == slashPos;
|
||||
const bool isRename = (*it)->_file.startsWith(parentDir) && (*it)->_file.lastIndexOf('/') == slashPos;
|
||||
|
||||
const bool isForbiddenSubDirectoryCreation = (*it)->isDirectory() && !destPerms.hasPermission(RemotePermissions::CanAddSubDirectories);
|
||||
const bool isForbiddenFileCreation = !(*it)->isDirectory() && !destPerms.hasPermission(RemotePermissions::CanAddFile);
|
||||
|
||||
// Check if we are allowed to move to the destination.
|
||||
bool destinationOK = true;
|
||||
if (isRename || destPerms.isNull()) {
|
||||
// no need to check for the destination dir permission
|
||||
destinationOK = true;
|
||||
} else if ((*it)->isDirectory() && !destPerms.hasPermission(RemotePermissions::CanAddSubDirectories)) {
|
||||
destinationOK = false;
|
||||
} else if (!(*it)->isDirectory() && !destPerms.hasPermission(RemotePermissions::CanAddFile)) {
|
||||
} else if (isForbiddenSubDirectoryCreation || isForbiddenFileCreation) {
|
||||
destinationOK = false;
|
||||
}
|
||||
|
||||
|
@ -1694,7 +1694,6 @@ void SyncEngine::restoreOldFiles(SyncFileItemVector &syncItems)
|
|||
case CSYNC_INSTRUCTION_NEW:
|
||||
// Ideally we should try to revert the rename or remove, but this would be dangerous
|
||||
// without re-doing the reconcile phase. So just let it happen.
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue