Added 'nodiscard' attribute to some of SyncJournalDb methods.

Signed-off-by: alex-z <blackslayer4@gmail.com>
This commit is contained in:
alex-z 2022-08-03 16:25:19 +03:00 committed by Matthieu Gallien
parent 35721cf746
commit 0b7813ee7a

View file

@ -59,24 +59,25 @@ public:
static bool maybeMigrateDb(const QString &localPath, const QString &absoluteJournalPath); static bool maybeMigrateDb(const QString &localPath, const QString &absoluteJournalPath);
// To verify that the record could be found check with SyncJournalFileRecord::isValid() // To verify that the record could be found check with SyncJournalFileRecord::isValid()
bool getFileRecord(const QString &filename, SyncJournalFileRecord *rec) { return getFileRecord(filename.toUtf8(), rec); } [[nodiscard]] bool getFileRecord(const QString &filename, SyncJournalFileRecord *rec) { return getFileRecord(filename.toUtf8(), rec); }
bool getFileRecord(const QByteArray &filename, SyncJournalFileRecord *rec); [[nodiscard]] bool getFileRecord(const QByteArray &filename, SyncJournalFileRecord *rec);
bool getFileRecordByE2eMangledName(const QString &mangledName, SyncJournalFileRecord *rec); [[nodiscard]] bool getFileRecordByE2eMangledName(const QString &mangledName, SyncJournalFileRecord *rec);
bool getFileRecordByInode(quint64 inode, SyncJournalFileRecord *rec); [[nodiscard]] bool getFileRecordByInode(quint64 inode, SyncJournalFileRecord *rec);
bool getFileRecordsByFileId(const QByteArray &fileId, const std::function<void(const SyncJournalFileRecord &)> &rowCallback); [[nodiscard]] bool getFileRecordsByFileId(const QByteArray &fileId, const std::function<void(const SyncJournalFileRecord &)> &rowCallback);
bool getFilesBelowPath(const QByteArray &path, const std::function<void(const SyncJournalFileRecord&)> &rowCallback); [[nodiscard]] bool getFilesBelowPath(const QByteArray &path, const std::function<void(const SyncJournalFileRecord&)> &rowCallback);
bool listFilesInPath(const QByteArray &path, const std::function<void(const SyncJournalFileRecord&)> &rowCallback); [[nodiscard]] bool listFilesInPath(const QByteArray &path, const std::function<void(const SyncJournalFileRecord&)> &rowCallback);
Result<void, QString> setFileRecord(const SyncJournalFileRecord &record); [[nodiscard]] Result<void, QString> setFileRecord(const SyncJournalFileRecord &record);
void keyValueStoreSet(const QString &key, QVariant value); void keyValueStoreSet(const QString &key, QVariant value);
qint64 keyValueStoreGetInt(const QString &key, qint64 defaultValue); [[nodiscard]] qint64 keyValueStoreGetInt(const QString &key, qint64 defaultValue);
void keyValueStoreDelete(const QString &key); void keyValueStoreDelete(const QString &key);
bool deleteFileRecord(const QString &filename, bool recursively = false); [[nodiscard]] bool deleteFileRecord(const QString &filename, bool recursively = false);
bool updateFileRecordChecksum(const QString &filename, [[nodiscard]] bool updateFileRecordChecksum(
const QString &filename,
const QByteArray &contentChecksum, const QByteArray &contentChecksum,
const QByteArray &contentChecksumType); const QByteArray &contentChecksumType);
bool updateLocalMetadata(const QString &filename, [[nodiscard]] bool updateLocalMetadata(const QString &filename,
qint64 modtime, qint64 size, quint64 inode); qint64 modtime, qint64 size, quint64 inode);
/// Return value for hasHydratedOrDehydratedFiles() /// Return value for hasHydratedOrDehydratedFiles()
@ -99,7 +100,7 @@ public:
void setErrorBlacklistEntry(const SyncJournalErrorBlacklistRecord &item); void setErrorBlacklistEntry(const SyncJournalErrorBlacklistRecord &item);
void wipeErrorBlacklistEntry(const QString &file); void wipeErrorBlacklistEntry(const QString &file);
void wipeErrorBlacklistCategory(SyncJournalErrorBlacklistRecord::Category category); void wipeErrorBlacklistCategory(SyncJournalErrorBlacklistRecord::Category category);
int wipeErrorBlacklist(); [[nodiscard]] int wipeErrorBlacklist();
int errorBlackListEntryCount(); int errorBlackListEntryCount();
struct DownloadInfo struct DownloadInfo
@ -145,7 +146,7 @@ public:
QVector<uint> deleteStaleUploadInfos(const QSet<QString> &keep); QVector<uint> deleteStaleUploadInfos(const QSet<QString> &keep);
SyncJournalErrorBlacklistRecord errorBlacklistEntry(const QString &); SyncJournalErrorBlacklistRecord errorBlacklistEntry(const QString &);
bool deleteStaleErrorBlacklistEntries(const QSet<QString> &keep); [[nodiscard]] bool deleteStaleErrorBlacklistEntries(const QSet<QString> &keep);
/// Delete flags table entries that have no metadata correspondent /// Delete flags table entries that have no metadata correspondent
void deleteStaleFlagsEntries(); void deleteStaleFlagsEntries();
@ -372,9 +373,9 @@ public:
private: private:
int getFileRecordCount(); int getFileRecordCount();
bool updateDatabaseStructure(); [[nodiscard]] bool updateDatabaseStructure();
bool updateMetadataTableStructure(); [[nodiscard]] bool updateMetadataTableStructure();
bool updateErrorBlacklistTableStructure(); [[nodiscard]] bool updateErrorBlacklistTableStructure();
bool sqlFail(const QString &log, const SqlQuery &query); bool sqlFail(const QString &log, const SqlQuery &query);
void commitInternal(const QString &context, bool startTrans = true); void commitInternal(const QString &context, bool startTrans = true);
void startTransaction(); void startTransaction();
@ -388,7 +389,7 @@ private:
// Returns the integer id of the checksum type // Returns the integer id of the checksum type
// //
// Returns 0 on failure and for empty checksum types. // Returns 0 on failure and for empty checksum types.
int mapChecksumType(const QByteArray &checksumType); [[nodiscard]] int mapChecksumType(const QByteArray &checksumType);
SqlDatabase _db; SqlDatabase _db;
QString _dbFile; QString _dbFile;