mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-19 22:24:19 +01:00
backup: restore default filename lightningd.sqlite3
This commit is contained in:
committed by
Christian Decker
parent
9591c1b31e
commit
be523aa54f
@@ -117,8 +117,12 @@ class Backend(object):
|
||||
|
||||
def restore(self, dest: str, remove_existing: bool = False):
|
||||
"""Restore the backup in this backend to its former glory.
|
||||
"""
|
||||
|
||||
If `dest` is a directory, we assume the default database filename:
|
||||
lightningd.sqlite3
|
||||
"""
|
||||
if os.path.isdir(dest):
|
||||
dest = os.path.join(dest, "lightningd.sqlite3")
|
||||
if os.path.exists(dest):
|
||||
if not remove_existing:
|
||||
raise ValueError(
|
||||
|
||||
@@ -192,6 +192,27 @@ def test_restore(node_factory, directory):
|
||||
subprocess.check_call([cli_path, "restore", bdest, rdest])
|
||||
|
||||
|
||||
def test_restore_dir(node_factory, directory):
|
||||
bpath = os.path.join(directory, 'lightning-1', 'regtest')
|
||||
bdest = 'file://' + os.path.join(bpath, 'backup.dbak')
|
||||
os.makedirs(bpath)
|
||||
subprocess.check_call([cli_path, "init", bpath, bdest])
|
||||
opts = {
|
||||
'plugin': plugin_path,
|
||||
'allow-deprecated-apis': deprecated_apis,
|
||||
}
|
||||
l1 = node_factory.get_node(options=opts, cleandir=False)
|
||||
l1.stop()
|
||||
|
||||
# should raise error without remove_existing
|
||||
with pytest.raises(Exception):
|
||||
subprocess.check_call([cli_path, "restore", bdest, bpath])
|
||||
|
||||
# but succeed when we remove the sqlite3 dbfile before
|
||||
os.remove(os.path.join(bpath, "lightningd.sqlite3"))
|
||||
subprocess.check_call([cli_path, "restore", bdest, bpath])
|
||||
|
||||
|
||||
def test_warning(directory, node_factory):
|
||||
bpath = os.path.join(directory, 'lightning-1', 'regtest')
|
||||
bdest = 'file://' + os.path.join(bpath, 'backup.dbak')
|
||||
|
||||
Reference in New Issue
Block a user