1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-24 04:57:45 +00:00

sagasu: Don't add duplicate folder nodes

This commit is contained in:
Joshua Goins 2023-10-12 19:29:06 -04:00
parent 4b19b7aeba
commit b1fa058d1d
2 changed files with 16 additions and 10 deletions

View file

@ -144,15 +144,21 @@ void FileTreeModel::addKnownFolder(QString string)
conct += QStringLiteral("/") + children[i];
}
std::string conctStd = conct.toStdString();
auto folderItem = new TreeInformation();
folderItem->name = children[i];
folderItem->type = TreeType::Folder;
folderItem->parent = parentItem;
folderItem->row = i + 1;
folderItem->hash = physis_generate_partial_hash(conctStd.c_str());
parentItem->children.push_back(folderItem);
parentItem = folderItem;
knownDirHashes[folderItem->hash] = folderItem;
auto hash = physis_generate_partial_hash(conctStd.c_str());
if (knownDirHashes.contains(hash)) {
parentItem = knownDirHashes[hash];
} else {
auto folderItem = new TreeInformation();
folderItem->name = children[i];
folderItem->type = TreeType::Folder;
folderItem->parent = parentItem;
folderItem->row = i + 1;
folderItem->hash = hash;
parentItem->children.push_back(folderItem);
parentItem = folderItem;
knownDirHashes[folderItem->hash] = folderItem;
}
}
}

View file

@ -42,7 +42,7 @@ void HashDatabase::addFile(QString file)
filename = file.sliced(lastSlash + 1, file.length() - lastSlash - 1);
}
qInfo() << filename;
qInfo() << "Adding" << filename;
std::string folderStd = filename.toStdString();