|
|
|
@ -29,7 +29,6 @@
@@ -29,7 +29,6 @@
|
|
|
|
|
#include "upgrade.h" |
|
|
|
|
|
|
|
|
|
#include <QMetaEnum> |
|
|
|
|
#include <QVector> |
|
|
|
|
|
|
|
|
|
#include "base/bittorrent/torrentcontentlayout.h" |
|
|
|
|
#include "base/logger.h" |
|
|
|
@ -43,7 +42,8 @@
@@ -43,7 +42,8 @@
|
|
|
|
|
|
|
|
|
|
namespace |
|
|
|
|
{ |
|
|
|
|
const int MIGRATION_VERSION = 1; |
|
|
|
|
const int MIGRATION_VERSION = 2; |
|
|
|
|
const char MIGRATION_VERSION_KEY[] = "Meta/MigrationVersion"; |
|
|
|
|
|
|
|
|
|
void exportWebUIHttpsFiles() |
|
|
|
|
{ |
|
|
|
@ -228,11 +228,109 @@ namespace
@@ -228,11 +228,109 @@ namespace
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void migrateSettingKeys() |
|
|
|
|
{ |
|
|
|
|
struct KeyMapping |
|
|
|
|
{ |
|
|
|
|
QString oldKey; |
|
|
|
|
QString newKey; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const KeyMapping mappings[] = |
|
|
|
|
{ |
|
|
|
|
{"AddNewTorrentDialog/Enabled", "Preferences/Downloads/NewAdditionDialog"}, |
|
|
|
|
{"AddNewTorrentDialog/Expanded", "AddNewTorrentDialog/expanded"}, |
|
|
|
|
{"AddNewTorrentDialog/Position", "AddNewTorrentDialog/y"}, |
|
|
|
|
{"AddNewTorrentDialog/SavePathHistory", "TorrentAdditionDlg/save_path_history"}, |
|
|
|
|
{"AddNewTorrentDialog/TopLevel", "Preferences/Downloads/NewAdditionDialogFront"}, |
|
|
|
|
{"AddNewTorrentDialog/TreeHeaderState", "AddNewTorrentDialog/qt5/treeHeaderState"}, |
|
|
|
|
{"AddNewTorrentDialog/Width", "AddNewTorrentDialog/width"}, |
|
|
|
|
{"BitTorrent/Session/AddExtensionToIncompleteFiles", "Preferences/Downloads/UseIncompleteExtension"}, |
|
|
|
|
{"BitTorrent/Session/AdditionalTrackers", "Preferences/Bittorrent/TrackersList"}, |
|
|
|
|
{"BitTorrent/Session/AddTorrentPaused", "Preferences/Downloads/StartInPause"}, |
|
|
|
|
{"BitTorrent/Session/AddTrackersEnabled", "Preferences/Bittorrent/AddTrackers"}, |
|
|
|
|
{"BitTorrent/Session/AlternativeGlobalDLSpeedLimit", "Preferences/Connection/GlobalDLLimitAlt"}, |
|
|
|
|
{"BitTorrent/Session/AlternativeGlobalUPSpeedLimit", "Preferences/Connection/GlobalUPLimitAlt"}, |
|
|
|
|
{"BitTorrent/Session/AnnounceIP", "Preferences/Connection/InetAddress"}, |
|
|
|
|
{"BitTorrent/Session/AnnounceToAllTrackers", "Preferences/Advanced/AnnounceToAllTrackers"}, |
|
|
|
|
{"BitTorrent/Session/AnonymousModeEnabled", "Preferences/Advanced/AnonymousMode"}, |
|
|
|
|
{"BitTorrent/Session/BandwidthSchedulerEnabled", "Preferences/Scheduler/Enabled"}, |
|
|
|
|
{"BitTorrent/Session/DefaultSavePath", "Preferences/Downloads/SavePath"}, |
|
|
|
|
{"BitTorrent/Session/DHTEnabled", "Preferences/Bittorrent/DHT"}, |
|
|
|
|
{"BitTorrent/Session/DiskCacheSize", "Preferences/Downloads/DiskWriteCacheSize"}, |
|
|
|
|
{"BitTorrent/Session/DiskCacheTTL", "Preferences/Downloads/DiskWriteCacheTTL"}, |
|
|
|
|
{"BitTorrent/Session/Encryption", "Preferences/Bittorrent/Encryption"}, |
|
|
|
|
{"BitTorrent/Session/FinishedTorrentExportDirectory", "Preferences/Downloads/FinishedTorrentExportDir"}, |
|
|
|
|
{"BitTorrent/Session/ForceProxy", "Preferences/Connection/ProxyForce"}, |
|
|
|
|
{"BitTorrent/Session/GlobalDLSpeedLimit", "Preferences/Connection/GlobalDLLimit"}, |
|
|
|
|
{"BitTorrent/Session/GlobalMaxRatio", "Preferences/Bittorrent/MaxRatio"}, |
|
|
|
|
{"BitTorrent/Session/GlobalUPSpeedLimit", "Preferences/Connection/GlobalUPLimit"}, |
|
|
|
|
{"BitTorrent/Session/IgnoreLimitsOnLAN", "Preferences/Advanced/IgnoreLimitsLAN"}, |
|
|
|
|
{"BitTorrent/Session/IgnoreSlowTorrentsForQueueing", "Preferences/Queueing/IgnoreSlowTorrents"}, |
|
|
|
|
{"BitTorrent/Session/IncludeOverheadInLimits", "Preferences/Advanced/IncludeOverhead"}, |
|
|
|
|
{"BitTorrent/Session/Interface", "Preferences/Connection/Interface"}, |
|
|
|
|
{"BitTorrent/Session/InterfaceAddress", "Preferences/Connection/InterfaceAddress"}, |
|
|
|
|
{"BitTorrent/Session/InterfaceName", "Preferences/Connection/InterfaceName"}, |
|
|
|
|
{"BitTorrent/Session/IPFilter", "Preferences/IPFilter/File"}, |
|
|
|
|
{"BitTorrent/Session/IPFilteringEnabled", "Preferences/IPFilter/Enabled"}, |
|
|
|
|
{"BitTorrent/Session/LSDEnabled", "Preferences/Bittorrent/LSD"}, |
|
|
|
|
{"BitTorrent/Session/MaxActiveDownloads", "Preferences/Queueing/MaxActiveDownloads"}, |
|
|
|
|
{"BitTorrent/Session/MaxActiveTorrents", "Preferences/Queueing/MaxActiveTorrents"}, |
|
|
|
|
{"BitTorrent/Session/MaxActiveUploads", "Preferences/Queueing/MaxActiveUploads"}, |
|
|
|
|
{"BitTorrent/Session/MaxConnections", "Preferences/Bittorrent/MaxConnecs"}, |
|
|
|
|
{"BitTorrent/Session/MaxConnectionsPerTorrent", "Preferences/Bittorrent/MaxConnecsPerTorrent"}, |
|
|
|
|
{"BitTorrent/Session/MaxHalfOpenConnections", "Preferences/Connection/MaxHalfOpenConnec"}, |
|
|
|
|
{"BitTorrent/Session/MaxRatioAction", "Preferences/Bittorrent/MaxRatioAction"}, |
|
|
|
|
{"BitTorrent/Session/MaxUploads", "Preferences/Bittorrent/MaxUploads"}, |
|
|
|
|
{"BitTorrent/Session/MaxUploadsPerTorrent", "Preferences/Bittorrent/MaxUploadsPerTorrent"}, |
|
|
|
|
{"BitTorrent/Session/OutgoingPortsMax", "Preferences/Advanced/OutgoingPortsMax"}, |
|
|
|
|
{"BitTorrent/Session/OutgoingPortsMin", "Preferences/Advanced/OutgoingPortsMin"}, |
|
|
|
|
{"BitTorrent/Session/PeXEnabled", "Preferences/Bittorrent/PeX"}, |
|
|
|
|
{"BitTorrent/Session/Port", "Preferences/Connection/PortRangeMin"}, |
|
|
|
|
{"BitTorrent/Session/Preallocation", "Preferences/Downloads/PreAllocation"}, |
|
|
|
|
{"BitTorrent/Session/ProxyPeerConnections", "Preferences/Connection/ProxyPeerConnections"}, |
|
|
|
|
{"BitTorrent/Session/QueueingSystemEnabled", "Preferences/Queueing/QueueingEnabled"}, |
|
|
|
|
{"BitTorrent/Session/RefreshInterval", "Preferences/General/RefreshInterval"}, |
|
|
|
|
{"BitTorrent/Session/SaveResumeDataInterval", "Preferences/Downloads/SaveResumeDataInterval"}, |
|
|
|
|
{"BitTorrent/Session/SuperSeedingEnabled", "Preferences/Advanced/SuperSeeding"}, |
|
|
|
|
{"BitTorrent/Session/TempPath", "Preferences/Downloads/TempPath"}, |
|
|
|
|
{"BitTorrent/Session/TempPathEnabled", "Preferences/Downloads/TempPathEnabled"}, |
|
|
|
|
{"BitTorrent/Session/TorrentExportDirectory", "Preferences/Downloads/TorrentExportDir"}, |
|
|
|
|
{"BitTorrent/Session/TrackerFilteringEnabled", "Preferences/IPFilter/FilterTracker"}, |
|
|
|
|
{"BitTorrent/Session/UseAlternativeGlobalSpeedLimit", "Preferences/Connection/alt_speeds_on"}, |
|
|
|
|
{"BitTorrent/Session/UseOSCache", "Preferences/Advanced/osCache"}, |
|
|
|
|
{"BitTorrent/Session/UseRandomPort", "Preferences/General/UseRandomPort"}, |
|
|
|
|
{"BitTorrent/Session/uTPEnabled", "Preferences/Bittorrent/uTP"}, |
|
|
|
|
{"BitTorrent/Session/uTPRateLimited", "Preferences/Bittorrent/uTP_rate_limited"}, |
|
|
|
|
{"BitTorrent/TrackerEnabled", "Preferences/Advanced/trackerEnabled"}, |
|
|
|
|
{"Network/PortForwardingEnabled", "Preferences/Connection/UPnP"}, |
|
|
|
|
{"Network/Proxy/Authentication", "Preferences/Connection/Proxy/Authentication"}, |
|
|
|
|
{"Network/Proxy/IP", "Preferences/Connection/Proxy/IP"}, |
|
|
|
|
{"Network/Proxy/OnlyForTorrents", "Preferences/Connection/ProxyOnlyForTorrents"}, |
|
|
|
|
{"Network/Proxy/Password", "Preferences/Connection/Proxy/Password"}, |
|
|
|
|
{"Network/Proxy/Port", "Preferences/Connection/Proxy/Port"}, |
|
|
|
|
{"Network/Proxy/Type", "Preferences/Connection/ProxyType"}, |
|
|
|
|
{"Network/Proxy/Username", "Preferences/Connection/Proxy/Username"}, |
|
|
|
|
{"State/BannedIPs", "Preferences/IPFilter/BannedIPs"} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
auto *settingsStorage = SettingsStorage::instance(); |
|
|
|
|
for (const KeyMapping &mapping : mappings) |
|
|
|
|
{ |
|
|
|
|
if (settingsStorage->hasKey(mapping.oldKey)) |
|
|
|
|
{ |
|
|
|
|
const auto value = settingsStorage->loadValue<QVariant>(mapping.oldKey); |
|
|
|
|
settingsStorage->storeValue(mapping.newKey, value); |
|
|
|
|
settingsStorage->removeValue(mapping.oldKey); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool upgrade(const bool /*ask*/) |
|
|
|
|
{ |
|
|
|
|
CachedSettingValue<int> version {"Meta/MigrationVersion", 0}; |
|
|
|
|
CachedSettingValue<int> version {MIGRATION_VERSION_KEY, 0}; |
|
|
|
|
|
|
|
|
|
if (version != MIGRATION_VERSION) |
|
|
|
|
{ |
|
|
|
@ -245,6 +343,8 @@ bool upgrade(const bool /*ask*/)
@@ -245,6 +343,8 @@ bool upgrade(const bool /*ask*/)
|
|
|
|
|
upgradeDNSServiceSettings(); |
|
|
|
|
upgradeTrayIconStyleSettings(); |
|
|
|
|
} |
|
|
|
|
if (version < 2) |
|
|
|
|
migrateSettingKeys(); |
|
|
|
|
|
|
|
|
|
version = MIGRATION_VERSION; |
|
|
|
|
} |
|
|
|
@ -252,6 +352,11 @@ bool upgrade(const bool /*ask*/)
@@ -252,6 +352,11 @@ bool upgrade(const bool /*ask*/)
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void setCurrentMigrationVersion() |
|
|
|
|
{ |
|
|
|
|
SettingsStorage::instance()->storeValue(QLatin1String(MIGRATION_VERSION_KEY), MIGRATION_VERSION); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void handleChangedDefaults(const DefaultPreferencesMode mode) |
|
|
|
|
{ |
|
|
|
|
struct DefaultValue |
|
|
|
@ -261,15 +366,18 @@ void handleChangedDefaults(const DefaultPreferencesMode mode)
@@ -261,15 +366,18 @@ void handleChangedDefaults(const DefaultPreferencesMode mode)
|
|
|
|
|
QVariant current; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const QVector<DefaultValue> changedDefaults |
|
|
|
|
const DefaultValue changedDefaults[] = |
|
|
|
|
{ |
|
|
|
|
{QLatin1String {"BitTorrent/Session/QueueingSystemEnabled"}, true, false} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
SettingsStorage *settingsStorage {SettingsStorage::instance()}; |
|
|
|
|
for (auto it = changedDefaults.cbegin(); it != changedDefaults.cend(); ++it) |
|
|
|
|
auto *settingsStorage = SettingsStorage::instance(); |
|
|
|
|
for (const DefaultValue &value : changedDefaults) |
|
|
|
|
{ |
|
|
|
|
if (!settingsStorage->hasKey(it->name)) |
|
|
|
|
settingsStorage->storeValue(it->name, (mode == DefaultPreferencesMode::Legacy ? it->legacy : it->current)); |
|
|
|
|
if (!settingsStorage->hasKey(value.name)) |
|
|
|
|
{ |
|
|
|
|
settingsStorage->storeValue(value.name |
|
|
|
|
, (mode == DefaultPreferencesMode::Legacy ? value.legacy : value.current)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|