Fix for database dump removal incorrectly skipping some database dumps.
This commit is contained in:
parent
375036e409
commit
d978a2d190
3 changed files with 16 additions and 11 deletions
1
NEWS
1
NEWS
|
@ -1,4 +1,5 @@
|
||||||
1.4.15
|
1.4.15
|
||||||
|
* Fix for database dump removal incorrectly skipping some database dumps.
|
||||||
* #123: Support for mounting an archive as a FUSE filesystem via "borgmatic mount" action, and
|
* #123: Support for mounting an archive as a FUSE filesystem via "borgmatic mount" action, and
|
||||||
unmounting via "borgmatic umount". See the documentation for more information:
|
unmounting via "borgmatic umount". See the documentation for more information:
|
||||||
https://torsion.org/borgmatic/docs/how-to/extract-a-backup/#mount-a-filesystem
|
https://torsion.org/borgmatic/docs/how-to/extract-a-backup/#mount-a-filesystem
|
||||||
|
|
|
@ -71,10 +71,10 @@ def remove_database_dumps(dump_path, databases, database_type_name, log_prefix,
|
||||||
continue
|
continue
|
||||||
|
|
||||||
os.remove(dump_filename)
|
os.remove(dump_filename)
|
||||||
dump_path = os.path.dirname(dump_filename)
|
dump_file_dir = os.path.dirname(dump_filename)
|
||||||
|
|
||||||
if len(os.listdir(dump_path)) == 0:
|
if len(os.listdir(dump_file_dir)) == 0:
|
||||||
os.rmdir(dump_path)
|
os.rmdir(dump_file_dir)
|
||||||
|
|
||||||
|
|
||||||
def convert_glob_patterns_to_borg_patterns(patterns):
|
def convert_glob_patterns_to_borg_patterns(patterns):
|
||||||
|
|
|
@ -51,16 +51,20 @@ def test_flatten_dump_patterns_with_no_hooks_errors():
|
||||||
|
|
||||||
def test_remove_database_dumps_removes_dump_for_each_database():
|
def test_remove_database_dumps_removes_dump_for_each_database():
|
||||||
databases = [{'name': 'foo'}, {'name': 'bar'}]
|
databases = [{'name': 'foo'}, {'name': 'bar'}]
|
||||||
flexmock(module).should_receive('make_database_dump_filename').and_return(
|
flexmock(module).should_receive('make_database_dump_filename').with_args(
|
||||||
'databases/localhost/foo'
|
'databases', 'foo', None
|
||||||
|
).and_return('databases/localhost/foo')
|
||||||
|
flexmock(module).should_receive('make_database_dump_filename').with_args(
|
||||||
|
'databases', 'bar', None
|
||||||
).and_return('databases/localhost/bar')
|
).and_return('databases/localhost/bar')
|
||||||
flexmock(module.os).should_receive('listdir').and_return([])
|
|
||||||
flexmock(module.os).should_receive('rmdir')
|
|
||||||
|
|
||||||
for name in ('foo', 'bar'):
|
flexmock(module.os).should_receive('remove').with_args('databases/localhost/foo').once()
|
||||||
flexmock(module.os).should_receive('remove').with_args(
|
flexmock(module.os).should_receive('remove').with_args('databases/localhost/bar').once()
|
||||||
'databases/localhost/{}'.format(name)
|
flexmock(module.os).should_receive('listdir').with_args('databases/localhost').and_return(
|
||||||
).once()
|
['bar']
|
||||||
|
).and_return([])
|
||||||
|
|
||||||
|
flexmock(module.os).should_receive('rmdir').with_args('databases/localhost').once()
|
||||||
|
|
||||||
module.remove_database_dumps('databases', databases, 'SuperDB', 'test.yaml', dry_run=False)
|
module.remove_database_dumps('databases', databases, 'SuperDB', 'test.yaml', dry_run=False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue