mirror of
https://github.com/redstrate/Novus.git
synced 2025-05-01 15:57:45 +00:00
I ran it through Hotspot, and it takes a *while* going back and forth with the database. The database is usually small enough to fit in memory, so we just do that instead.
35 lines
No EOL
773 B
C++
35 lines
No EOL
773 B
C++
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QSqlDatabase>
|
|
#include <QSqlQuery>
|
|
|
|
class HashDatabase : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit HashDatabase(QObject *parent = nullptr);
|
|
|
|
void addFolder(const QString &folder);
|
|
void addFile(const QString &file);
|
|
void importFileList(const QByteArray &file);
|
|
|
|
QVector<QString> getKnownFolders();
|
|
|
|
bool knowsFile(uint32_t i);
|
|
|
|
QString getFilename(uint32_t i);
|
|
|
|
private:
|
|
void cacheDatabase();
|
|
|
|
QSqlDatabase m_db;
|
|
|
|
// Database transactions are super slow, so we keep a copy in memory
|
|
QHash<uint32_t, QString> m_fileHashes;
|
|
QHash<uint32_t, QString> m_folderHashes;
|
|
}; |