Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when opening conflict dialog #2948

Merged
merged 2 commits into from
Mar 5, 2021
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
18 changes: 16 additions & 2 deletions src/gui/tray/UserModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,29 @@ void User::slotAddError(const QString &folderAlias, const QString &message, Erro
}
}

bool User::isValueableActivity(const Folder *folder, const SyncFileItemPtr &item) const
{
// Ignore activity from a different account
if (folder->accountState() != _account.data()) {
return false;
}

// We just care about conflict issues that we are able to resolve
if (item->_status == SyncFileItem::Conflict && !Utility::isConflictFile(item->_file)) {
return false;
}

return true;
}

void User::slotItemCompleted(const QString &folder, const SyncFileItemPtr &item)
{
auto folderInstance = FolderMan::instance()->folder(folder);

if (!folderInstance)
return;

// check if we are adding it to the right account and if it is useful information (protocol errors)
if (folderInstance->accountState() == _account.data()) {
if (isValueableActivity(folderInstance, item)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch, this is subpar API naming, what is "valueable"? It will tell me nothing months from now. I think it was better not factoring this out in a method but instead store the result in two nicely named booleans and combine then in the if. Typically something like:

const auto isForUserAccount = folderInstance->accountState() == _account.data();
const auto isUnresolvableConflict = item->_status == SyncFileItem::Conflict && !Utility::isConflictFile(item->_file);
if (isForUserAccount && !isUnresolvableConflict) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FlexW I guess we still have time to create a PR with just these changes :) @er-vin Sorry, we had to make it move forward. I must confess, I am not that nitpicky reviewer :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@er-vin @allexzander pr for that #2976

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@er-vin Sorry, we had to make it move forward.

No worries, I'm less available that's how it is. :-)

I must confess, I am not that nitpicky reviewer :)

Well, I know I put quite some nitpicks too, but there it was really more of a code smell. If something is not clearly named for some reason and one can't find a proper name for it... well something is fishy. ;-)

qCWarning(lcActivity) << "Item " << item->_file << " retrieved resulted in " << item->_errorString;

Activity activity;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/tray/UserModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public slots:
void connectPushNotifications() const;
bool checkPushNotificationsAreReady() const;

bool isValueableActivity(const Folder *folder, const SyncFileItemPtr &item) const;

private:
AccountStatePtr _account;
bool _isCurrentUser;
Expand Down
7 changes: 3 additions & 4 deletions src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,13 +742,12 @@ bool OwncloudPropagator::createConflict(const SyncFileItemPtr &item,
conflictItem->_size = item->_previousSize;
emit newItem(conflictItem);
composite->appendTask(conflictItem);
} else {
// Directories we can't process in one go. The next sync run
// will take care of uploading the conflict dir contents.
_anotherSyncNeeded = true;
}
}

// Need a new sync to detect the created copy of the conflicting file
_anotherSyncNeeded = true;

return true;
}

Expand Down