mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 01:11:35 +00:00
kivy: make backups optional
This commit is contained in:
parent
d9172ade71
commit
e3ccfe6449
4 changed files with 20 additions and 6 deletions
|
@ -164,6 +164,10 @@ class ElectrumWindow(App):
|
|||
def on_use_rbf(self, instance, x):
|
||||
self.electrum_config.set_key('use_rbf', self.use_rbf, True)
|
||||
|
||||
android_backups = BooleanProperty(False)
|
||||
def on_android_backups(self, instance, x):
|
||||
self.electrum_config.set_key('android_backups', self.android_backups, True)
|
||||
|
||||
use_change = BooleanProperty(False)
|
||||
def on_use_change(self, instance, x):
|
||||
if self.wallet:
|
||||
|
@ -1252,7 +1256,7 @@ class ElectrumWindow(App):
|
|||
if new_path:
|
||||
self.show_info(_("Backup saved:") + f"\n{new_path}")
|
||||
else:
|
||||
self.show_error(_("Backup NOT saved. Backup directory or password not configured."))
|
||||
self.show_error(_("Backup NOT saved. Backup directory not configured."))
|
||||
|
||||
def export_private_keys(self, pk_label, addr):
|
||||
if self.wallet.is_watching_only():
|
||||
|
|
|
@ -89,6 +89,13 @@ Builder.load_string('''
|
|||
title: _('Password')
|
||||
description: _("Change wallet password.")
|
||||
action: root.change_password
|
||||
CardSeparator
|
||||
SettingsItem:
|
||||
status: _('Yes') if app.android_backups else _('No')
|
||||
title: _('Backups') + ': ' + self.status
|
||||
description: _("Backup wallet to external storage.")
|
||||
message: _("If this option is checked, a backup of your wallet will be written to external storage everytime you create a new channel. Make sure your wallet is protected with a strong password before you enable this option.")
|
||||
action: partial(root.boolean_dialog, 'android_backups', _('Backups'), self.message)
|
||||
|
||||
# disabled: there is currently only one coin selection policy
|
||||
#CardSeparator
|
||||
|
|
|
@ -441,8 +441,10 @@ def android_data_dir():
|
|||
return PythonActivity.mActivity.getFilesDir().getPath() + '/data'
|
||||
|
||||
def get_backup_dir(config):
|
||||
return android_backup_dir() if 'ANDROID_DATA' in os.environ else config.get('backup_dir')
|
||||
|
||||
if 'ANDROID_DATA' in os.environ:
|
||||
return android_backup_dir() if config.get('android_backups') else None
|
||||
else:
|
||||
return config.get('backup_dir')
|
||||
|
||||
def ensure_sparse_file(filename):
|
||||
# On modern Linux, no need to do anything.
|
||||
|
|
|
@ -264,11 +264,12 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
|||
self.db.write(self.storage)
|
||||
|
||||
def save_backup(self):
|
||||
backup_dir = get_backup_dir(self.config)
|
||||
if backup_dir is None:
|
||||
return
|
||||
new_db = WalletDB(self.db.dump(), manual_upgrades=False)
|
||||
new_db.put('is_backup', True)
|
||||
new_path = os.path.join(get_backup_dir(self.config), self.basename() + '.backup')
|
||||
if new_path is None:
|
||||
return
|
||||
new_path = os.path.join(backup_dir, self.basename() + '.backup')
|
||||
new_storage = WalletStorage(new_path)
|
||||
new_storage._encryption_version = self.storage._encryption_version
|
||||
new_storage.pubkey = self.storage.pubkey
|
||||
|
|
Loading…
Add table
Reference in a new issue