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

[KDESKTOP-1248] Fix crash in Node::deleteChildren caused by empty root node #329

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
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,25 @@ ExitCode UpdateTreeWorker::step5CreateDirectory() {
continue;
}

if (createOp->path().empty()) {
LOG_SYNCPAL_WARN(_logger, "Invalid create operation on nodeId=" << createOp->nodeId().c_str());
assert(false);
SentryHandler::instance()->captureMessage(SentryLevel::Warning, "UpdateTreeWorker::step5CreateDirectory",
"Invalid create operation");
continue;
}

// find node by path because it may have been created before
std::shared_ptr<Node> currentNode = getOrCreateNodeFromExistingPath(createOp->path());
if (currentNode == nullptr) {
LOG_SYNCPAL_WARN(_logger, "Error in UpdateTreeWorker::getOrCreateNodeFromExistingPath");
return ExitCode::DataError;
luc-guyot-infomaniak marked this conversation as resolved.
Show resolved Hide resolved
} else if (currentNode == _updateTree->rootNode()) {
LOG_SYNCPAL_WARN(_logger, "No operation allowed on the root node");
luc-guyot-infomaniak marked this conversation as resolved.
Show resolved Hide resolved
assert(false);
return ExitCode::DataError;
}

if (currentNode->hasChangeEvent(OperationType::Delete)) {
// A directory has been deleted and another one has been created with the same name
currentNode->setPreviousId(currentNode->id());
Expand Down Expand Up @@ -978,6 +995,12 @@ ExitCode UpdateTreeWorker::createMoveNodes(const NodeType &nodeType) {
bool UpdateTreeWorker::updateNodeId(std::shared_ptr<Node> node, const NodeId &newId) {
const NodeId oldId = node->id().has_value() ? *node->id() : "";

if (!node->parentNode()) {
LOG_SYNCPAL_WARN(_logger, "Bad parameters");
luc-guyot-infomaniak marked this conversation as resolved.
Show resolved Hide resolved
assert(false);
return false;
}

node->parentNode()->deleteChildren(node);
node->setId(newId);

Expand Down
Loading