mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-16 13:11:36 +03:00
Move old RSS items to separate config file. Closes #6167.
--HG-- branch : magao-dev
This commit is contained in:
parent
7be27f7770
commit
cecff159a0
3 changed files with 30 additions and 8 deletions
|
@ -141,6 +141,10 @@ int main(int argc, char *argv[])
|
||||||
macMigratePlists();
|
macMigratePlists();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef DISABLE_GUI
|
||||||
|
migrateRSS();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Create Application
|
// Create Application
|
||||||
QString appId = QLatin1String("qBittorrent-") + Utils::Misc::getUserIDString();
|
QString appId = QLatin1String("qBittorrent-") + Utils::Misc::getUserIDString();
|
||||||
QScopedPointer<Application> app(new Application(appId, argc, argv));
|
QScopedPointer<Application> app(new Application(appId, argc, argv));
|
||||||
|
|
|
@ -228,7 +228,6 @@ bool upgrade(bool ask = true)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
void migratePlistToIni(const QString &application)
|
void migratePlistToIni(const QString &application)
|
||||||
{
|
{
|
||||||
|
@ -257,5 +256,22 @@ void macMigratePlists()
|
||||||
}
|
}
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
|
#ifndef DISABLE_GUI
|
||||||
|
void migrateRSS()
|
||||||
|
{
|
||||||
|
// Copy old feed items to new file if needed
|
||||||
|
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss-feeds");
|
||||||
|
if (!qBTRSS.allKeys().isEmpty()) return; // We move the contents of RSS old_items only if inifile does not exist (is empty).
|
||||||
|
|
||||||
|
QIniSettings qBTRSSLegacy("qBittorrent", "qBittorrent-rss");
|
||||||
|
QHash<QString, QVariant> allOldItems = qBTRSSLegacy.value("old_items", QHash<QString, QVariant>()).toHash();
|
||||||
|
|
||||||
|
if (!allOldItems.empty()) {
|
||||||
|
qDebug("Moving %d old items for feeds to qBittorrent-rss-feeds", allOldItems.size());
|
||||||
|
qBTRSS.setValue("old_items", allOldItems);
|
||||||
|
qBTRSSLegacy.remove("old_items");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // UPGRADE_H
|
#endif // UPGRADE_H
|
||||||
|
|
|
@ -99,7 +99,7 @@ void Feed::saveItemsToDisk()
|
||||||
|
|
||||||
m_dirty = false;
|
m_dirty = false;
|
||||||
|
|
||||||
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
|
QIniSettings qBTRSSFeeds("qBittorrent", "qBittorrent-rss-feeds");
|
||||||
QVariantList oldItems;
|
QVariantList oldItems;
|
||||||
|
|
||||||
ArticleHash::ConstIterator it = m_articles.begin();
|
ArticleHash::ConstIterator it = m_articles.begin();
|
||||||
|
@ -107,15 +107,16 @@ void Feed::saveItemsToDisk()
|
||||||
for (; it != itend; ++it)
|
for (; it != itend; ++it)
|
||||||
oldItems << it.value()->toHash();
|
oldItems << it.value()->toHash();
|
||||||
qDebug("Saving %d old items for feed %s", oldItems.size(), qPrintable(displayName()));
|
qDebug("Saving %d old items for feed %s", oldItems.size(), qPrintable(displayName()));
|
||||||
QHash<QString, QVariant> allOldItems = qBTRSS.value("old_items", QHash<QString, QVariant>()).toHash();
|
QHash<QString, QVariant> allOldItems = qBTRSSFeeds.value("old_items", QHash<QString, QVariant>()).toHash();
|
||||||
allOldItems[m_url] = oldItems;
|
allOldItems[m_url] = oldItems;
|
||||||
qBTRSS.setValue("old_items", allOldItems);
|
qBTRSSFeeds.setValue("old_items", allOldItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Feed::loadItemsFromDisk()
|
void Feed::loadItemsFromDisk()
|
||||||
{
|
{
|
||||||
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
|
QIniSettings qBTRSSFeeds("qBittorrent", "qBittorrent-rss-feeds");
|
||||||
QHash<QString, QVariant> allOldItems = qBTRSS.value("old_items", QHash<QString, QVariant>()).toHash();
|
QHash<QString, QVariant> allOldItems = qBTRSSFeeds.value("old_items", QHash<QString, QVariant>()).toHash();
|
||||||
|
|
||||||
const QVariantList oldItems = allOldItems.value(m_url, QVariantList()).toList();
|
const QVariantList oldItems = allOldItems.value(m_url, QVariantList()).toList();
|
||||||
qDebug("Loading %d old items for feed %s", oldItems.size(), qPrintable(displayName()));
|
qDebug("Loading %d old items for feed %s", oldItems.size(), qPrintable(displayName()));
|
||||||
|
|
||||||
|
@ -203,10 +204,11 @@ void Feed::removeAllSettings()
|
||||||
allFeedsFilters.remove(m_url);
|
allFeedsFilters.remove(m_url);
|
||||||
qBTRSS.setValue("feed_filters", allFeedsFilters);
|
qBTRSS.setValue("feed_filters", allFeedsFilters);
|
||||||
}
|
}
|
||||||
QVariantHash allOldItems = qBTRSS.value("old_items", QVariantHash()).toHash();
|
QIniSettings qBTRSSFeeds("qBittorrent", "qBittorrent-rss-feeds");
|
||||||
|
QVariantHash allOldItems = qBTRSSFeeds.value("old_items", QVariantHash()).toHash();
|
||||||
if (allOldItems.contains(m_url)) {
|
if (allOldItems.contains(m_url)) {
|
||||||
allOldItems.remove(m_url);
|
allOldItems.remove(m_url);
|
||||||
qBTRSS.setValue("old_items", allOldItems);
|
qBTRSSFeeds.setValue("old_items", allOldItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue