Line data Source code
1 : #include "UpdateFeedURLOperation.h"
2 : #include "../utilities/FangLogging.h"
3 :
4 2 : UpdateFeedURLOperation::UpdateFeedURLOperation(OperationManager *parent, FeedItem* feed, QUrl newURL) :
5 : DBOperation(parent),
6 2 : feed(feed),
7 2 : newURL(newURL)
8 : {
9 2 : }
10 :
11 2 : void UpdateFeedURLOperation::execute()
12 : {
13 4 : qCDebug(logOperation) << "Updating feed URL from " << feed->getURL() << " to " << newURL;
14 :
15 2 : db().transaction();
16 :
17 : // Update URL
18 2 : QSqlQuery query(db());
19 2 : query.prepare("UPDATE FeedItemTable SET url = :url WHERE id = :feed_id");
20 2 : query.bindValue(":feed_id", feed->getDbID());
21 2 : query.bindValue(":url", newURL);
22 :
23 2 : if (!query.exec()) {
24 0 : reportSQLError(query, "Unable to update feed URL");
25 0 : db().rollback();
26 :
27 0 : return;
28 : }
29 :
30 2 : db().commit();
31 2 : feed->setURL(newURL); // May or may not be needed, shouldn't hurt either way.
32 2 : }
|