Skip to content

Commit

Permalink
Allow multiple items simultaneously in updateGameDataOnDiskState()
Browse files Browse the repository at this point in the history
  • Loading branch information
oblivioncth committed Nov 9, 2023
1 parent cce4548 commit 4cf088d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/include/fp/fp-db.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class FP_FP_EXPORT Db : public QObject
// Helper
DbError getEntry(std::variant<Game, AddApp>& entry, const QUuid& entryId);
DbError getGameData(GameData& data, const QUuid& gameId);
DbError updateGameDataOnDiskState(int packId, bool onDisk);
DbError updateGameDataOnDiskState(QList<int> packIds, bool onDisk);

//-Slots ------------------------------------------------------------------------------------------------------
private:
Expand Down
5 changes: 3 additions & 2 deletions lib/src/fp-db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ DbError Db::getGameData(GameData& data, const QUuid& gameId)
return DbError();
}

DbError Db::updateGameDataOnDiskState(int packId, bool onDisk)
DbError Db::updateGameDataOnDiskState(QList<int> packIds, bool onDisk)
{
// Get database
QSqlDatabase fpDb;
Expand All @@ -862,8 +862,9 @@ DbError Db::updateGameDataOnDiskState(int packId, bool onDisk)
return DbError::fromSqlError(dbError);

// Make query
QString filter = Qx::String::join(packIds, [](int i){ return QString::number(i); }, u","_s);
QString dataUpdateCommand = u"UPDATE "_s + Table_Game_Data::NAME + u" SET "_s + Table_Game_Data::COL_PRES_ON_DISK + u" = "_s + QString::number(onDisk) +
u" WHERE "_s + Table_Game_Data::COL_ID + u" = "_s + QString::number(packId);
u" WHERE "_s + Table_Game_Data::COL_ID + u" IN ("_s + filter + ')';

QSqlQuery packUpdateQuery(fpDb);
packUpdateQuery.setForwardOnly(true);
Expand Down

0 comments on commit 4cf088d

Please sign in to comment.