Continue update of episodes even if gpodder server is unavailable

This commit is contained in:
Bart De Vries 2022-06-09 12:38:00 +02:00
parent 8097ffe513
commit c44abc66ba
1 changed files with 84 additions and 60 deletions

View File

@ -211,14 +211,37 @@ void SyncJob::syncSubscriptions()
if (subRequest->error() || subRequest->aborted()) { if (subRequest->error() || subRequest->aborted()) {
if (subRequest->aborted()) { if (subRequest->aborted()) {
Q_EMIT infoMessage(this, getProgressMessage(Aborted)); Q_EMIT infoMessage(this, getProgressMessage(Aborted));
emitResult();
return;
} else if (subRequest->error()) { } else if (subRequest->error()) {
setError(SyncJobError::SubscriptionDownloadError); setError(SyncJobError::SubscriptionDownloadError);
setErrorText(subRequest->errorString()); setErrorText(subRequest->errorString());
Q_EMIT infoMessage(this, getProgressMessage(Error)); Q_EMIT infoMessage(this, getProgressMessage(Error));
} }
// If this is a force sync (i.e. processing all updates), then
// continue with fetching podcasts updates, otherwise it's not
// possible to update new episodes if the sync server happens to be
// down or is not reachable.
if (m_forceFetchAll) {
QSqlQuery query;
query.prepare(QStringLiteral("SELECT url FROM Feeds;"));
Database::instance().execute(query);
while (query.next()) {
QString url = query.value(0).toString();
if (!m_feedsToBeUpdatedSubs.contains(url)) {
m_feedsToBeUpdatedSubs += url;
}
}
m_feedUpdateTotal = m_feedsToBeUpdatedSubs.count();
setProcessedAmount(KJob::Unit::Items, processedAmount(KJob::Unit::Items) + 2); // skip upload step
Q_EMIT infoMessage(this, getProgressMessage(SubscriptionFetch));
QTimer::singleShot(0, this, &SyncJob::fetchModifiedSubscriptions);
} else {
emitResult(); emitResult();
return; return;
} }
} else {
qCDebug(kastsSync) << "Finished device update request"; qCDebug(kastsSync) << "Finished device update request";
qulonglong newSubscriptionTimestamp = subRequest->timestamp(); qulonglong newSubscriptionTimestamp = subRequest->timestamp();
@ -288,6 +311,7 @@ void SyncJob::syncSubscriptions()
QTimer::singleShot(0, this, [=]() { QTimer::singleShot(0, this, [=]() {
uploadSubscriptions(localAddFeedList, localRemoveFeedList); uploadSubscriptions(localAddFeedList, localRemoveFeedList);
}); });
}
}); });
} }