From: APTX Date: Fri, 1 Jun 2012 16:59:45 +0000 (+0200) Subject: Read/update should be a transaction. Read default mylist state from config. X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=1f1b993a064b7a691768e8ce0303c76e147cec71;p=localmylist.git Read/update should be a transaction. Read default mylist state from config. --- diff --git a/localmylist/requesthandler.cpp b/localmylist/requesthandler.cpp index 9b1ba1a..3944478 100644 --- a/localmylist/requesthandler.cpp +++ b/localmylist/requesthandler.cpp @@ -1,5 +1,6 @@ #include "requesthandler.h" +#include "mylist.h" #include "database.h" #include @@ -123,6 +124,7 @@ void RequestHandler::animeRequestComplete(bool success) if (!success) return; + db->transaction(); // If entry exists we get to update fields we know. // Entry might exist just with my values and aid from vote command Anime next = db->getAnime(reply->command().aid()); @@ -151,6 +153,7 @@ void RequestHandler::animeRequestComplete(bool success) db->addAnime(next); else db->setAnime(next); + db->commit(); // my values obtained with VoteCommand @@ -173,6 +176,7 @@ void RequestHandler::episodeRequestComplete(bool success) if (!success) return; + db->transaction(); Episode next = db->getEpisode(reply->command().eid()); bool isNew = !next.eid; @@ -201,6 +205,7 @@ void RequestHandler::episodeRequestComplete(bool success) db->addEpisode(next); else db->setEpisode(next); + db->commit(); // Obtain my values VoteReply *voteReply = Client::instance()->send(VoteCommand(VoteCommand::AnimeVote, next.aid, VoteCommand::Retrieve, reply->epnoAsInt())); @@ -222,6 +227,7 @@ void RequestHandler::fileRequestComplete(bool success) if (!success) return; + db->transaction(); // Fid might not be known in command File next = db->getFile(reply->fid()); @@ -287,6 +293,7 @@ void RequestHandler::fileRequestComplete(bool success) db->addRequest(request); } } + db->commit(); // File is not in mylist if (!reply->lid()) @@ -294,6 +301,11 @@ void RequestHandler::fileRequestComplete(bool success) MyListAddCommand cmd(next.fid); cmd.setEd2k(reply->ed2k()); cmd.setSize(reply->size()); + cmd.setViewed(MyList::instance()->settings()->get("myListDefaultViewed").toBool()); + cmd.setState(State(MyList::instance()->settings()->get("myListDefaultState").toInt())); + cmd.setSource(MyList::instance()->settings()->get("myListDefaultSource").toString()); + cmd.setStorage(MyList::instance()->settings()->get("myListDefaultStorage").toString()); + cmd.setOther(MyList::instance()->settings()->get("myListDefaultOther").toString()); MyListAddReply *addReply = Client::instance()->send(cmd); connect(addReply, SIGNAL(replyReady(bool)), this, SLOT(myListAddReplyRecieved(bool))); return;