Possible solution for #150.

This commit is contained in:
Martin Rotter 2017-10-26 20:26:42 +02:00
parent 79557e71e2
commit 245c0b08c3
3 changed files with 8 additions and 5 deletions

View File

@ -167,7 +167,7 @@ void Feed::run() {
<< customId() << " in thread: \'"
<< QThread::currentThreadId() << "\'.";
bool error_during_obtaining;
bool error_during_obtaining = false;
QList<Message> msgs = obtainNewMessages(&error_during_obtaining);
qDebug().nospace() << "Downloaded " << msgs.size() << " messages for feed "
@ -215,7 +215,7 @@ int Feed::updateMessages(const QList<Message>& messages, bool error_during_obtai
qDebug("Updating messages in DB. Main thread: '%s'.", qPrintable(is_main_thread ? "true" : "false"));
if (!error_during_obtaining) {
if (!messages.isEmpty()) {
bool anything_updated = false;
bool ok = true;
@ -241,8 +241,9 @@ int Feed::updateMessages(const QList<Message>& messages, bool error_during_obtai
}
}
}
else {
qCritical("I skip saving of messages into DB, as we have error during their downloading indicated.");
if (error_during_obtaining) {
qCritical("There is indication that there was error during messages obtaining.");
}
items_to_update.append(this);

View File

@ -16,7 +16,7 @@ InoreaderServiceRoot* InoreaderFeed::serviceRoot() const {
}
QList<Message> InoreaderFeed::obtainNewMessages(bool* error_during_obtaining) {
Feed::Status error;
Feed::Status error = Feed::Status::Normal;
QList<Message> messages = serviceRoot()->network()->messages(customId(), error);
setStatus(error);

View File

@ -113,6 +113,7 @@ QList<Message> InoreaderNetworkFactory::messages(const QString& stream_id, Feed:
QString bearer = m_oauth2->bearer().toLocal8Bit();
if (bearer.isEmpty()) {
qCritical("Cannot download messages for '%s', bearer is empty.", qPrintable(stream_id));
error = Feed::Status::AuthError;
return QList<Message>();
}
@ -126,6 +127,7 @@ QList<Message> InoreaderNetworkFactory::messages(const QString& stream_id, Feed:
loop.exec();
if (downloader.lastOutputError() != QNetworkReply::NetworkError::NoError) {
qCritical("Cannot download messages for '%s', network error.", qPrintable(stream_id));
error = Feed::Status::NetworkError;
return QList<Message>();
}