2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2019 Mike Tzou (Chocobo1)
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * In addition, as a special exception, the copyright holders give permission to
20 * link this program with the OpenSSL project's "OpenSSL" library (or with
21 * modified versions of it that use the same license as the "OpenSSL" library),
22 * and distribute the linked executables. You must obey the GNU General Public
23 * License in all respects for all of the code used other than "OpenSSL". If you
24 * modify file(s), you may extend this exception to your version of the file(s),
25 * but you are not obligated to do so. If you do not wish to do so, delete this
26 * exception statement from your version.
31 #include <QtSystemDetection>
32 #include <QCoreApplication>
35 #include "base/bittorrent/sharelimitaction.h"
36 #include "base/bittorrent/torrentcontentlayout.h"
37 #include "base/global.h"
38 #include "base/logger.h"
39 #include "base/net/proxyconfigurationmanager.h"
40 #include "base/preferences.h"
41 #include "base/profile.h"
42 #include "base/settingsstorage.h"
43 #include "base/settingvalue.h"
44 #include "base/utils/io.h"
45 #include "base/utils/string.h"
49 const int MIGRATION_VERSION
= 8;
50 const QString MIGRATION_VERSION_KEY
= u
"Meta/MigrationVersion"_s
;
52 void exportWebUIHttpsFiles()
54 const auto migrate
= [](const QString
&oldKey
, const QString
&newKey
, const Path
&savePath
)
56 SettingsStorage
*settingsStorage
{SettingsStorage::instance()};
57 const auto oldData
{settingsStorage
->loadValue
<QByteArray
>(oldKey
)};
58 const auto newData
{settingsStorage
->loadValue
<QString
>(newKey
)};
59 const QString errorMsgFormat
{QCoreApplication::translate("Upgrade", "Migrate preferences failed: WebUI https, file: \"%1\", error: \"%2\"")};
61 if (!newData
.isEmpty() || oldData
.isEmpty())
64 const nonstd::expected
<void, QString
> result
= Utils::IO::saveToFile(savePath
, oldData
);
67 LogMsg(errorMsgFormat
.arg(savePath
.toString(), result
.error()) , Log::WARNING
);
71 settingsStorage
->storeValue(newKey
, savePath
);
72 settingsStorage
->removeValue(oldKey
);
74 LogMsg(QCoreApplication::translate("Upgrade", "Migrated preferences: WebUI https, exported data to file: \"%1\"").arg(savePath
.toString())
78 const Path configPath
= specialFolderLocation(SpecialFolder::Config
);
79 migrate(u
"Preferences/WebUI/HTTPS/Certificate"_s
80 , u
"Preferences/WebUI/HTTPS/CertificatePath"_s
81 , (configPath
/ Path(u
"WebUICertificate.crt"_s
)));
82 migrate(u
"Preferences/WebUI/HTTPS/Key"_s
83 , u
"Preferences/WebUI/HTTPS/KeyPath"_s
84 , (configPath
/ Path(u
"WebUIPrivateKey.pem"_s
)));
87 void upgradeTorrentContentLayout()
89 const QString oldKey
= u
"BitTorrent/Session/CreateTorrentSubfolder"_s
;
90 const QString newKey
= u
"BitTorrent/Session/TorrentContentLayout"_s
;
92 SettingsStorage
*settingsStorage
{SettingsStorage::instance()};
93 const auto oldData
{settingsStorage
->loadValue
<QVariant
>(oldKey
)};
94 const auto newData
{settingsStorage
->loadValue
<QString
>(newKey
)};
96 if (!newData
.isEmpty() || !oldData
.isValid())
99 const bool createSubfolder
= oldData
.toBool();
100 const BitTorrent::TorrentContentLayout torrentContentLayout
=
101 (createSubfolder
? BitTorrent::TorrentContentLayout::Original
: BitTorrent::TorrentContentLayout::NoSubfolder
);
103 settingsStorage
->storeValue(newKey
, Utils::String::fromEnum(torrentContentLayout
));
104 settingsStorage
->removeValue(oldKey
);
107 void upgradeListenPortSettings()
109 const auto oldKey
= u
"BitTorrent/Session/UseRandomPort"_s
;
110 const auto newKey
= u
"Preferences/Connection/PortRangeMin"_s
;
111 auto *settingsStorage
= SettingsStorage::instance();
113 if (settingsStorage
->hasKey(oldKey
))
115 if (settingsStorage
->loadValue
<bool>(oldKey
))
116 settingsStorage
->storeValue(newKey
, 0);
118 settingsStorage
->removeValue(oldKey
);
122 void upgradeSchedulerDaysSettings()
124 auto *settingsStorage
= SettingsStorage::instance();
125 const auto key
= u
"Preferences/Scheduler/days"_s
;
126 const auto value
= settingsStorage
->loadValue
<QString
>(key
);
129 const auto number
= value
.toInt(&ok
);
136 settingsStorage
->storeValue(key
, Scheduler::Days::EveryDay
);
139 settingsStorage
->storeValue(key
, Scheduler::Days::Weekday
);
142 settingsStorage
->storeValue(key
, Scheduler::Days::Weekend
);
145 settingsStorage
->storeValue(key
, Scheduler::Days::Monday
);
148 settingsStorage
->storeValue(key
, Scheduler::Days::Tuesday
);
151 settingsStorage
->storeValue(key
, Scheduler::Days::Wednesday
);
154 settingsStorage
->storeValue(key
, Scheduler::Days::Thursday
);
157 settingsStorage
->storeValue(key
, Scheduler::Days::Friday
);
160 settingsStorage
->storeValue(key
, Scheduler::Days::Saturday
);
163 settingsStorage
->storeValue(key
, Scheduler::Days::Sunday
);
166 LogMsg(QCoreApplication::translate("Upgrade", "Invalid value found in configuration file, reverting it to default. Key: \"%1\". Invalid value: \"%2\".")
167 .arg(key
, QString::number(number
)), Log::WARNING
);
168 settingsStorage
->removeValue(key
);
174 void upgradeDNSServiceSettings()
176 auto *settingsStorage
= SettingsStorage::instance();
177 const auto key
= u
"Preferences/DynDNS/Service"_s
;
178 const auto value
= settingsStorage
->loadValue
<QString
>(key
);
181 const auto number
= value
.toInt(&ok
);
188 settingsStorage
->storeValue(key
, DNS::Service::None
);
191 settingsStorage
->storeValue(key
, DNS::Service::DynDNS
);
194 settingsStorage
->storeValue(key
, DNS::Service::NoIP
);
197 LogMsg(QCoreApplication::translate("Upgrade", "Invalid value found in configuration file, reverting it to default. Key: \"%1\". Invalid value: \"%2\".")
198 .arg(key
, QString::number(number
)), Log::WARNING
);
199 settingsStorage
->removeValue(key
);
205 void upgradeTrayIconStyleSettings()
207 auto *settingsStorage
= SettingsStorage::instance();
208 const auto key
= u
"Preferences/Advanced/TrayIconStyle"_s
;
209 const auto value
= settingsStorage
->loadValue
<QString
>(key
);
212 const auto number
= value
.toInt(&ok
);
219 settingsStorage
->storeValue(key
, TrayIcon::Style::Normal
);
222 settingsStorage
->storeValue(key
, TrayIcon::Style::MonoDark
);
225 settingsStorage
->storeValue(key
, TrayIcon::Style::MonoLight
);
228 LogMsg(QCoreApplication::translate("Upgrade", "Invalid value found in configuration file, reverting it to default. Key: \"%1\". Invalid value: \"%2\".")
229 .arg(key
, QString::number(number
)), Log::WARNING
);
230 settingsStorage
->removeValue(key
);
236 void migrateSettingKeys()
244 const KeyMapping mappings
[] =
246 {u
"AddNewTorrentDialog/Enabled"_s
, u
"Preferences/Downloads/NewAdditionDialog"_s
},
247 {u
"AddNewTorrentDialog/Expanded"_s
, u
"AddNewTorrentDialog/expanded"_s
},
248 {u
"AddNewTorrentDialog/Position"_s
, u
"AddNewTorrentDialog/y"_s
},
249 {u
"AddNewTorrentDialog/SavePathHistory"_s
, u
"TorrentAdditionDlg/save_path_history"_s
},
250 {u
"AddNewTorrentDialog/TopLevel"_s
, u
"Preferences/Downloads/NewAdditionDialogFront"_s
},
251 {u
"AddNewTorrentDialog/TreeHeaderState"_s
, u
"AddNewTorrentDialog/qt5/treeHeaderState"_s
},
252 {u
"AddNewTorrentDialog/Width"_s
, u
"AddNewTorrentDialog/width"_s
},
253 {u
"BitTorrent/Session/AddExtensionToIncompleteFiles"_s
, u
"Preferences/Downloads/UseIncompleteExtension"_s
},
254 {u
"BitTorrent/Session/AdditionalTrackers"_s
, u
"Preferences/Bittorrent/TrackersList"_s
},
255 {u
"BitTorrent/Session/AddTorrentPaused"_s
, u
"Preferences/Downloads/StartInPause"_s
},
256 {u
"BitTorrent/Session/AddTrackersEnabled"_s
, u
"Preferences/Bittorrent/AddTrackers"_s
},
257 {u
"BitTorrent/Session/AlternativeGlobalDLSpeedLimit"_s
, u
"Preferences/Connection/GlobalDLLimitAlt"_s
},
258 {u
"BitTorrent/Session/AlternativeGlobalUPSpeedLimit"_s
, u
"Preferences/Connection/GlobalUPLimitAlt"_s
},
259 {u
"BitTorrent/Session/AnnounceIP"_s
, u
"Preferences/Connection/InetAddress"_s
},
260 {u
"BitTorrent/Session/AnnounceToAllTrackers"_s
, u
"Preferences/Advanced/AnnounceToAllTrackers"_s
},
261 {u
"BitTorrent/Session/AnonymousModeEnabled"_s
, u
"Preferences/Advanced/AnonymousMode"_s
},
262 {u
"BitTorrent/Session/BandwidthSchedulerEnabled"_s
, u
"Preferences/Scheduler/Enabled"_s
},
263 {u
"BitTorrent/Session/DefaultSavePath"_s
, u
"Preferences/Downloads/SavePath"_s
},
264 {u
"BitTorrent/Session/DHTEnabled"_s
, u
"Preferences/Bittorrent/DHT"_s
},
265 {u
"BitTorrent/Session/DiskCacheSize"_s
, u
"Preferences/Downloads/DiskWriteCacheSize"_s
},
266 {u
"BitTorrent/Session/DiskCacheTTL"_s
, u
"Preferences/Downloads/DiskWriteCacheTTL"_s
},
267 {u
"BitTorrent/Session/Encryption"_s
, u
"Preferences/Bittorrent/Encryption"_s
},
268 {u
"BitTorrent/Session/FinishedTorrentExportDirectory"_s
, u
"Preferences/Downloads/FinishedTorrentExportDir"_s
},
269 {u
"BitTorrent/Session/ForceProxy"_s
, u
"Preferences/Connection/ProxyForce"_s
},
270 {u
"BitTorrent/Session/GlobalDLSpeedLimit"_s
, u
"Preferences/Connection/GlobalDLLimit"_s
},
271 {u
"BitTorrent/Session/GlobalMaxRatio"_s
, u
"Preferences/Bittorrent/MaxRatio"_s
},
272 {u
"BitTorrent/Session/GlobalUPSpeedLimit"_s
, u
"Preferences/Connection/GlobalUPLimit"_s
},
273 {u
"BitTorrent/Session/IgnoreLimitsOnLAN"_s
, u
"Preferences/Advanced/IgnoreLimitsLAN"_s
},
274 {u
"BitTorrent/Session/IgnoreSlowTorrentsForQueueing"_s
, u
"Preferences/Queueing/IgnoreSlowTorrents"_s
},
275 {u
"BitTorrent/Session/IncludeOverheadInLimits"_s
, u
"Preferences/Advanced/IncludeOverhead"_s
},
276 {u
"BitTorrent/Session/Interface"_s
, u
"Preferences/Connection/Interface"_s
},
277 {u
"BitTorrent/Session/InterfaceAddress"_s
, u
"Preferences/Connection/InterfaceAddress"_s
},
278 {u
"BitTorrent/Session/InterfaceName"_s
, u
"Preferences/Connection/InterfaceName"_s
},
279 {u
"BitTorrent/Session/IPFilter"_s
, u
"Preferences/IPFilter/File"_s
},
280 {u
"BitTorrent/Session/IPFilteringEnabled"_s
, u
"Preferences/IPFilter/Enabled"_s
},
281 {u
"BitTorrent/Session/LSDEnabled"_s
, u
"Preferences/Bittorrent/LSD"_s
},
282 {u
"BitTorrent/Session/MaxActiveDownloads"_s
, u
"Preferences/Queueing/MaxActiveDownloads"_s
},
283 {u
"BitTorrent/Session/MaxActiveTorrents"_s
, u
"Preferences/Queueing/MaxActiveTorrents"_s
},
284 {u
"BitTorrent/Session/MaxActiveUploads"_s
, u
"Preferences/Queueing/MaxActiveUploads"_s
},
285 {u
"BitTorrent/Session/MaxConnections"_s
, u
"Preferences/Bittorrent/MaxConnecs"_s
},
286 {u
"BitTorrent/Session/MaxConnectionsPerTorrent"_s
, u
"Preferences/Bittorrent/MaxConnecsPerTorrent"_s
},
287 {u
"BitTorrent/Session/MaxHalfOpenConnections"_s
, u
"Preferences/Connection/MaxHalfOpenConnec"_s
},
288 {u
"BitTorrent/Session/MaxRatioAction"_s
, u
"Preferences/Bittorrent/MaxRatioAction"_s
},
289 {u
"BitTorrent/Session/MaxUploads"_s
, u
"Preferences/Bittorrent/MaxUploads"_s
},
290 {u
"BitTorrent/Session/MaxUploadsPerTorrent"_s
, u
"Preferences/Bittorrent/MaxUploadsPerTorrent"_s
},
291 {u
"BitTorrent/Session/OutgoingPortsMax"_s
, u
"Preferences/Advanced/OutgoingPortsMax"_s
},
292 {u
"BitTorrent/Session/OutgoingPortsMin"_s
, u
"Preferences/Advanced/OutgoingPortsMin"_s
},
293 {u
"BitTorrent/Session/PeXEnabled"_s
, u
"Preferences/Bittorrent/PeX"_s
},
294 {u
"BitTorrent/Session/Port"_s
, u
"Preferences/Connection/PortRangeMin"_s
},
295 {u
"BitTorrent/Session/Preallocation"_s
, u
"Preferences/Downloads/PreAllocation"_s
},
296 {u
"BitTorrent/Session/ProxyPeerConnections"_s
, u
"Preferences/Connection/ProxyPeerConnections"_s
},
297 {u
"BitTorrent/Session/QueueingSystemEnabled"_s
, u
"Preferences/Queueing/QueueingEnabled"_s
},
298 {u
"BitTorrent/Session/RefreshInterval"_s
, u
"Preferences/General/RefreshInterval"_s
},
299 {u
"BitTorrent/Session/SaveResumeDataInterval"_s
, u
"Preferences/Downloads/SaveResumeDataInterval"_s
},
300 {u
"BitTorrent/Session/SuperSeedingEnabled"_s
, u
"Preferences/Advanced/SuperSeeding"_s
},
301 {u
"BitTorrent/Session/TempPath"_s
, u
"Preferences/Downloads/TempPath"_s
},
302 {u
"BitTorrent/Session/TempPathEnabled"_s
, u
"Preferences/Downloads/TempPathEnabled"_s
},
303 {u
"BitTorrent/Session/TorrentExportDirectory"_s
, u
"Preferences/Downloads/TorrentExportDir"_s
},
304 {u
"BitTorrent/Session/TrackerFilteringEnabled"_s
, u
"Preferences/IPFilter/FilterTracker"_s
},
305 {u
"BitTorrent/Session/UseAlternativeGlobalSpeedLimit"_s
, u
"Preferences/Connection/alt_speeds_on"_s
},
306 {u
"BitTorrent/Session/UseOSCache"_s
, u
"Preferences/Advanced/osCache"_s
},
307 {u
"BitTorrent/Session/UseRandomPort"_s
, u
"Preferences/General/UseRandomPort"_s
},
308 {u
"BitTorrent/Session/uTPEnabled"_s
, u
"Preferences/Bittorrent/uTP"_s
},
309 {u
"BitTorrent/Session/uTPRateLimited"_s
, u
"Preferences/Bittorrent/uTP_rate_limited"_s
},
310 {u
"BitTorrent/TrackerEnabled"_s
, u
"Preferences/Advanced/trackerEnabled"_s
},
311 {u
"Network/PortForwardingEnabled"_s
, u
"Preferences/Connection/UPnP"_s
},
312 {u
"Network/Proxy/Authentication"_s
, u
"Preferences/Connection/Proxy/Authentication"_s
},
313 {u
"Network/Proxy/IP"_s
, u
"Preferences/Connection/Proxy/IP"_s
},
314 {u
"Network/Proxy/OnlyForTorrents"_s
, u
"Preferences/Connection/ProxyOnlyForTorrents"_s
},
315 {u
"Network/Proxy/Password"_s
, u
"Preferences/Connection/Proxy/Password"_s
},
316 {u
"Network/Proxy/Port"_s
, u
"Preferences/Connection/Proxy/Port"_s
},
317 {u
"Network/Proxy/Type"_s
, u
"Preferences/Connection/ProxyType"_s
},
318 {u
"Network/Proxy/Username"_s
, u
"Preferences/Connection/Proxy/Username"_s
},
319 {u
"State/BannedIPs"_s
, u
"Preferences/IPFilter/BannedIPs"_s
}
322 auto *settingsStorage
= SettingsStorage::instance();
323 for (const KeyMapping
&mapping
: mappings
)
325 if (settingsStorage
->hasKey(mapping
.oldKey
))
327 const auto value
= settingsStorage
->loadValue
<QVariant
>(mapping
.oldKey
);
328 settingsStorage
->storeValue(mapping
.newKey
, value
);
329 // TODO: Remove oldKey after ~v4.4.3 and bump migration version
334 void migrateProxySettingsEnum()
336 auto *settingsStorage
= SettingsStorage::instance();
337 const auto key
= u
"Network/Proxy/Type"_s
;
338 const auto value
= settingsStorage
->loadValue
<QString
>(key
);
341 const auto number
= value
.toInt(&ok
);
348 settingsStorage
->storeValue(key
, Net::ProxyType::None
);
351 settingsStorage
->storeValue(key
, Net::ProxyType::HTTP
);
354 settingsStorage
->storeValue(key
, Net::ProxyType::SOCKS5
);
357 settingsStorage
->storeValue(key
, u
"HTTP_PW"_s
);
360 settingsStorage
->storeValue(key
, u
"SOCKS5_PW"_s
);
363 settingsStorage
->storeValue(key
, Net::ProxyType::SOCKS4
);
366 LogMsg(QCoreApplication::translate("Upgrade", "Invalid value found in configuration file, reverting it to default. Key: \"%1\". Invalid value: \"%2\".")
367 .arg(key
, QString::number(number
)), Log::WARNING
);
368 settingsStorage
->removeValue(key
);
374 void migrateProxySettings()
376 auto *settingsStorage
= SettingsStorage::instance();
377 const auto proxyType
= settingsStorage
->loadValue
<QString
>(u
"Network/Proxy/Type"_s
, u
"None"_s
);
378 const auto onlyForTorrents
= settingsStorage
->loadValue
<bool>(u
"Network/Proxy/OnlyForTorrents"_s
)
379 || (proxyType
== u
"SOCKS4");
381 settingsStorage
->storeValue(u
"Network/Proxy/Profiles/BitTorrent"_s
, true);
382 settingsStorage
->storeValue(u
"Network/Proxy/Profiles/RSS"_s
, !onlyForTorrents
);
383 settingsStorage
->storeValue(u
"Network/Proxy/Profiles/Misc"_s
, !onlyForTorrents
);
385 if (proxyType
== u
"HTTP_PW"_s
)
387 settingsStorage
->storeValue(u
"Network/Proxy/Type"_s
, Net::ProxyType::HTTP
);
388 settingsStorage
->storeValue(u
"Network/Proxy/AuthEnabled"_s
, true);
390 else if (proxyType
== u
"SOCKS5_PW"_s
)
392 settingsStorage
->storeValue(u
"Network/Proxy/Type"_s
, Net::ProxyType::SOCKS5
);
393 settingsStorage
->storeValue(u
"Network/Proxy/AuthEnabled"_s
, true);
396 settingsStorage
->removeValue(u
"Network/Proxy/OnlyForTorrents"_s
);
398 const auto proxyHostnameLookup
= settingsStorage
->loadValue
<bool>(u
"BitTorrent/Session/ProxyHostnameLookup"_s
);
399 settingsStorage
->storeValue(u
"Network/Proxy/HostnameLookupEnabled"_s
, proxyHostnameLookup
);
400 settingsStorage
->removeValue(u
"BitTorrent/Session/ProxyHostnameLookup"_s
);
404 void migrateMemoryPrioritySettings()
406 auto *settingsStorage
= SettingsStorage::instance();
407 const QString oldKey
= u
"BitTorrent/OSMemoryPriority"_s
;
408 const QString newKey
= u
"Application/ProcessMemoryPriority"_s
;
410 if (settingsStorage
->hasKey(oldKey
))
412 const auto value
= settingsStorage
->loadValue
<QVariant
>(oldKey
);
413 settingsStorage
->storeValue(newKey
, value
);
418 void migrateStartupWindowState()
420 auto *settingsStorage
= SettingsStorage::instance();
421 if (settingsStorage
->hasKey(u
"Preferences/General/StartMinimized"_s
))
423 const auto startMinimized
= settingsStorage
->loadValue
<bool>(u
"Preferences/General/StartMinimized"_s
);
424 const auto minimizeToTray
= settingsStorage
->loadValue
<bool>(u
"Preferences/General/MinimizeToTray"_s
);
425 const QString windowState
= startMinimized
? (minimizeToTray
? u
"Hidden"_s
: u
"Minimized"_s
) : u
"Normal"_s
;
426 settingsStorage
->storeValue(u
"GUI/StartUpWindowState"_s
, windowState
);
430 void migrateChineseLocale()
432 auto *settingsStorage
= SettingsStorage::instance();
433 const auto key
= u
"Preferences/General/Locale"_s
;
434 if (settingsStorage
->hasKey(key
))
436 const auto locale
= settingsStorage
->loadValue
<QString
>(key
);
437 if (locale
.compare(u
"zh"_s
, Qt::CaseInsensitive
) == 0)
438 settingsStorage
->storeValue(key
, u
"zh_CN"_s
);
442 void migrateShareLimitActionSettings()
444 auto *settingsStorage
= SettingsStorage::instance();
445 const auto oldKey
= u
"BitTorrent/Session/MaxRatioAction"_s
;
446 const auto newKey
= u
"BitTorrent/Session/ShareLimitAction"_s
;
447 const auto value
= settingsStorage
->loadValue
<int>(oldKey
);
452 settingsStorage
->storeValue(newKey
, BitTorrent::ShareLimitAction::Stop
);
455 settingsStorage
->storeValue(newKey
, BitTorrent::ShareLimitAction::Remove
);
458 settingsStorage
->storeValue(newKey
, BitTorrent::ShareLimitAction::EnableSuperSeeding
);
461 settingsStorage
->storeValue(newKey
, BitTorrent::ShareLimitAction::RemoveWithContent
);
464 LogMsg(QCoreApplication::translate("Upgrade", "Invalid value found in configuration file, reverting it to default. Key: \"%1\". Invalid value: \"%2\".")
465 .arg(oldKey
, QString::number(value
)), Log::WARNING
);
469 settingsStorage
->removeValue(oldKey
);
472 void migrateAddPausedSetting()
474 auto *settingsStorage
= SettingsStorage::instance();
475 const auto oldKey
= u
"BitTorrent/Session/AddTorrentPaused"_s
;
476 const auto newKey
= u
"BitTorrent/Session/AddTorrentStopped"_s
;
478 settingsStorage
->storeValue(newKey
, settingsStorage
->loadValue
<bool>(oldKey
));
479 settingsStorage
->removeValue(oldKey
);
485 CachedSettingValue
<int> version
{MIGRATION_VERSION_KEY
, 0};
487 if (version
!= MIGRATION_VERSION
)
491 exportWebUIHttpsFiles();
492 upgradeTorrentContentLayout();
493 upgradeListenPortSettings();
494 upgradeSchedulerDaysSettings();
495 upgradeDNSServiceSettings();
496 upgradeTrayIconStyleSettings();
500 migrateSettingKeys();
503 migrateProxySettingsEnum();
507 migrateMemoryPrioritySettings();
512 migrateStartupWindowState();
513 migrateChineseLocale();
517 migrateProxySettings();
520 migrateShareLimitActionSettings();
523 migrateAddPausedSetting();
525 version
= MIGRATION_VERSION
;
531 void setCurrentMigrationVersion()
533 SettingsStorage::instance()->storeValue(MIGRATION_VERSION_KEY
, MIGRATION_VERSION
);
536 void handleChangedDefaults(const DefaultPreferencesMode mode
)
545 const DefaultValue changedDefaults
[] =
547 {u
"BitTorrent/Session/QueueingSystemEnabled"_s
, true, false}
550 auto *settingsStorage
= SettingsStorage::instance();
551 for (const DefaultValue
&value
: changedDefaults
)
553 if (!settingsStorage
->hasKey(value
.name
))
555 settingsStorage
->storeValue(value
.name
556 , (mode
== DefaultPreferencesMode::Legacy
? value
.legacy
: value
.current
));