mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[Server+Client] Tombstone deck deletes with purge and base snapshots
This commit is contained in:
parent
2916fa45af
commit
e43862c3bc
8 changed files with 180 additions and 21 deletions
|
|
@ -709,7 +709,8 @@ bool AbstractServerSocketInterface::deckListHelper(int folderId,
|
|||
|
||||
query = sqlInterface->prepareQuery("select id, name, upload_time, is_public, banner_card_name, "
|
||||
"banner_card_provider, color_identity, tags, guid, hash, last_modified from "
|
||||
"{prefix}_decklist_files where id_folder = :id_folder and id_user = :id_user");
|
||||
"{prefix}_decklist_files where id_folder = :id_folder and id_user = :id_user "
|
||||
"and deleted = 0");
|
||||
query->bindValue(":id_folder", folderId);
|
||||
query->bindValue(":id_user", userId);
|
||||
if (!sqlInterface->execSqlQuery(query)) {
|
||||
|
|
@ -854,8 +855,8 @@ Response::ResponseCode AbstractServerSocketInterface::cmdDeckSetVisibility(const
|
|||
sqlInterface->checkSql();
|
||||
|
||||
if (cmd.has_deck_id()) {
|
||||
QSqlQuery *query =
|
||||
sqlInterface->prepareQuery("select 1 from {prefix}_decklist_files where id = :id and id_user = :id_user");
|
||||
QSqlQuery *query = sqlInterface->prepareQuery(
|
||||
"select 1 from {prefix}_decklist_files where id = :id and id_user = :id_user and deleted = 0");
|
||||
query->bindValue(":id", cmd.deck_id());
|
||||
query->bindValue(":id_user", userInfo->id());
|
||||
sqlInterface->execSqlQuery(query);
|
||||
|
|
@ -965,7 +966,8 @@ void AbstractServerSocketInterface::deckDelDirHelper(int basePathId)
|
|||
deckDelDirHelper(query->value(0).toInt());
|
||||
}
|
||||
|
||||
query = sqlInterface->prepareQuery("delete from {prefix}_decklist_files where id_folder = :id_folder");
|
||||
query = sqlInterface->prepareQuery("update {prefix}_decklist_files set deleted = 1, last_modified = NOW() "
|
||||
"where id_folder = :id_folder and deleted = 0");
|
||||
query->bindValue(":id_folder", basePathId);
|
||||
sqlInterface->execSqlQuery(query);
|
||||
|
||||
|
|
@ -1016,18 +1018,17 @@ Response::ResponseCode AbstractServerSocketInterface::cmdDeckDel(const Command_D
|
|||
|
||||
sqlInterface->checkSql();
|
||||
QSqlQuery *query =
|
||||
sqlInterface->prepareQuery("select id from {prefix}_decklist_files where id = :id and id_user = :id_user");
|
||||
sqlInterface->prepareQuery("update {prefix}_decklist_files set deleted = 1, last_modified = NOW() where id = "
|
||||
":id and id_user = :id_user and deleted = 0");
|
||||
query->bindValue(":id", cmd.deck_id());
|
||||
query->bindValue(":id_user", userInfo->id());
|
||||
sqlInterface->execSqlQuery(query);
|
||||
if (!query->next()) {
|
||||
if (!sqlInterface->execSqlQuery(query)) {
|
||||
return Response::RespContextError;
|
||||
}
|
||||
if (query->numRowsAffected() == 0) {
|
||||
return Response::RespNameNotFound;
|
||||
}
|
||||
|
||||
query = sqlInterface->prepareQuery("delete from {prefix}_decklist_files where id = :id");
|
||||
query->bindValue(":id", cmd.deck_id());
|
||||
sqlInterface->execSqlQuery(query);
|
||||
|
||||
return Response::RespOk;
|
||||
}
|
||||
|
||||
|
|
@ -1197,9 +1198,11 @@ Response::ResponseCode AbstractServerSocketInterface::cmdDeckUpload(const Comman
|
|||
}
|
||||
const QString oldHash = currentQuery->value(1).toString();
|
||||
|
||||
QString updateQuery = "update {prefix}_decklist_files set name=:name, upload_time=NOW(), content=:content, "
|
||||
"banner_card_name=:banner_card_name, banner_card_provider=:banner_card_provider, "
|
||||
"color_identity=:color_identity, tags=:tags, guid=:guid, hash=:hash, last_modified=NOW()";
|
||||
QString updateQuery =
|
||||
"update {prefix}_decklist_files set name=:name, upload_time=NOW(), content=:content, "
|
||||
"banner_card_name=:banner_card_name, banner_card_provider=:banner_card_provider, "
|
||||
"color_identity=:color_identity, tags=:tags, guid=:guid, hash=:hash, last_modified=NOW(), "
|
||||
"deleted=0";
|
||||
if (cmd.has_is_public()) {
|
||||
updateQuery += ", is_public=:is_public";
|
||||
}
|
||||
|
|
@ -1401,7 +1404,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdDeckShareCreate(const C
|
|||
// issues its own query on the same cached statement set.
|
||||
QSqlQuery *query =
|
||||
sqlInterface->prepareQuery("select id, color_identity from {prefix}_decklist_files where id_folder = "
|
||||
":id_folder and id_user = :id_user");
|
||||
":id_folder and id_user = :id_user and deleted = 0");
|
||||
query->bindValue(":id_folder", folderId);
|
||||
query->bindValue(":id_user", userInfo->id());
|
||||
if (!sqlInterface->execSqlQuery(query)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue