mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
check name conflicts when loading nodes
This commit is contained in:
parent
73ebcaeb90
commit
08fe335a80
@ -4,6 +4,7 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QDebug>
|
||||
#include <QSet>
|
||||
|
||||
#include <notebookbackend/inotebookbackend.h>
|
||||
#include <notebook/notebookparameters.h>
|
||||
@ -170,6 +171,8 @@ QSharedPointer<Node> VXNotebookConfigMgr::nodeConfigToNode(const NodeConfig &p_c
|
||||
|
||||
void VXNotebookConfigMgr::loadFolderNode(Node *p_node, const NodeConfig &p_config)
|
||||
{
|
||||
QSet<QString> seenNames;
|
||||
|
||||
QVector<QSharedPointer<Node>> children;
|
||||
children.reserve(p_config.m_files.size() + p_config.m_folders.size());
|
||||
const auto basePath = p_node->fetchPath();
|
||||
@ -183,6 +186,12 @@ void VXNotebookConfigMgr::loadFolderNode(Node *p_node, const NodeConfig &p_confi
|
||||
continue;
|
||||
}
|
||||
|
||||
if (seenNames.contains(folder.m_name)) {
|
||||
qWarning() << "skipped loading node with duplicated name under" << p_node->fetchPath();
|
||||
continue;
|
||||
}
|
||||
seenNames.insert(folder.m_name);
|
||||
|
||||
auto folderNode = QSharedPointer<VXNode>::create(folder.m_name,
|
||||
getNotebook(),
|
||||
p_node);
|
||||
@ -198,6 +207,12 @@ void VXNotebookConfigMgr::loadFolderNode(Node *p_node, const NodeConfig &p_confi
|
||||
continue;
|
||||
}
|
||||
|
||||
if (seenNames.contains(file.m_name)) {
|
||||
qWarning() << "skipped loading node with duplicated name under" << p_node->fetchPath();
|
||||
continue;
|
||||
}
|
||||
seenNames.insert(file.m_name);
|
||||
|
||||
// For compability only.
|
||||
needUpdateConfig = needUpdateConfig || file.m_signature == Node::InvalidId;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user