mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 17:55:20 +00:00
follow-up re #4491, do config upgrade to keep base unit settings on kivy
This commit is contained in:
parent
1635c149bd
commit
46fd7c3d8b
1 changed files with 15 additions and 1 deletions
|
@ -37,7 +37,7 @@ def set_config(c):
|
||||||
config = c
|
config = c
|
||||||
|
|
||||||
|
|
||||||
FINAL_CONFIG_VERSION = 2
|
FINAL_CONFIG_VERSION = 3
|
||||||
|
|
||||||
|
|
||||||
class SimpleConfig(PrintError):
|
class SimpleConfig(PrintError):
|
||||||
|
@ -164,6 +164,7 @@ class SimpleConfig(PrintError):
|
||||||
self.print_error('upgrading config')
|
self.print_error('upgrading config')
|
||||||
|
|
||||||
self.convert_version_2()
|
self.convert_version_2()
|
||||||
|
self.convert_version_3()
|
||||||
|
|
||||||
self.set_key('config_version', FINAL_CONFIG_VERSION, save=True)
|
self.set_key('config_version', FINAL_CONFIG_VERSION, save=True)
|
||||||
|
|
||||||
|
@ -186,6 +187,19 @@ class SimpleConfig(PrintError):
|
||||||
|
|
||||||
self.set_key('config_version', 2)
|
self.set_key('config_version', 2)
|
||||||
|
|
||||||
|
def convert_version_3(self):
|
||||||
|
if not self._is_upgrade_method_needed(2, 2):
|
||||||
|
return
|
||||||
|
|
||||||
|
base_unit = self.user_config.get('base_unit')
|
||||||
|
if isinstance(base_unit, str):
|
||||||
|
self._set_key_in_user_config('base_unit', None)
|
||||||
|
map_ = {'btc':8, 'mbtc':5, 'ubtc':2, 'bits':2, 'sat':0}
|
||||||
|
decimal_point = map_.get(base_unit.lower())
|
||||||
|
self._set_key_in_user_config('decimal_point', decimal_point)
|
||||||
|
|
||||||
|
self.set_key('config_version', 3)
|
||||||
|
|
||||||
def _is_upgrade_method_needed(self, min_version, max_version):
|
def _is_upgrade_method_needed(self, min_version, max_version):
|
||||||
cur_version = self.get_config_version()
|
cur_version = self.get_config_version()
|
||||||
if cur_version > max_version:
|
if cur_version > max_version:
|
||||||
|
|
Loading…
Add table
Reference in a new issue