Checks: '-*,
bugprone-argument-comment,
+ bugprone-branch-clone,
cppcoreguidelines-init-variables,
misc-*,
-misc-non-private-member-variables-in-classes,
}();
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.
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
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) {
} 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
{
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);
}
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);
// 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());
}
// 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) {
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:
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;
}
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;
}