mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Get rid of misleading/old 'no_compress' option
This commit is contained in:
parent
835701d590
commit
42f430d234
3 changed files with 14 additions and 27 deletions
|
@ -852,10 +852,6 @@ backup:
|
||||||
-o:
|
-o:
|
||||||
full: --output-directory
|
full: --output-directory
|
||||||
help: Output directory for the backup
|
help: Output directory for the backup
|
||||||
-r:
|
|
||||||
full: --no-compress
|
|
||||||
help: Do not create an archive file
|
|
||||||
action: store_true
|
|
||||||
--methods:
|
--methods:
|
||||||
help: List of backup methods to apply (copy or tar by default)
|
help: List of backup methods to apply (copy or tar by default)
|
||||||
nargs: "*"
|
nargs: "*"
|
||||||
|
|
|
@ -1976,7 +1976,7 @@ class CustomBackupMethod(BackupMethod):
|
||||||
#
|
#
|
||||||
|
|
||||||
def backup_create(name=None, description=None, methods=[],
|
def backup_create(name=None, description=None, methods=[],
|
||||||
output_directory=None, no_compress=False,
|
output_directory=None,
|
||||||
system=[], apps=[]):
|
system=[], apps=[]):
|
||||||
"""
|
"""
|
||||||
Create a backup local archive
|
Create a backup local archive
|
||||||
|
@ -1986,7 +1986,6 @@ def backup_create(name=None, description=None, methods=[],
|
||||||
description -- Short description of the backup
|
description -- Short description of the backup
|
||||||
method -- Method of backup to use
|
method -- Method of backup to use
|
||||||
output_directory -- Output directory for the backup
|
output_directory -- Output directory for the backup
|
||||||
no_compress -- Do not create an archive file
|
|
||||||
system -- List of system elements to backup
|
system -- List of system elements to backup
|
||||||
apps -- List of application names to backup
|
apps -- List of application names to backup
|
||||||
"""
|
"""
|
||||||
|
@ -2001,6 +2000,10 @@ def backup_create(name=None, description=None, methods=[],
|
||||||
if name and name in backup_list()['archives']:
|
if name and name in backup_list()['archives']:
|
||||||
raise YunohostError('backup_archive_name_exists')
|
raise YunohostError('backup_archive_name_exists')
|
||||||
|
|
||||||
|
# By default we backup using the tar method
|
||||||
|
if not methods:
|
||||||
|
methods = ['tar']
|
||||||
|
|
||||||
# Validate output_directory option
|
# Validate output_directory option
|
||||||
if output_directory:
|
if output_directory:
|
||||||
output_directory = os.path.abspath(output_directory)
|
output_directory = os.path.abspath(output_directory)
|
||||||
|
@ -2011,20 +2014,12 @@ def backup_create(name=None, description=None, methods=[],
|
||||||
output_directory):
|
output_directory):
|
||||||
raise YunohostError('backup_output_directory_forbidden')
|
raise YunohostError('backup_output_directory_forbidden')
|
||||||
|
|
||||||
|
if "copy" in methods:
|
||||||
|
if not output_directory:
|
||||||
|
raise YunohostError('backup_output_directory_required')
|
||||||
# Check that output directory is empty
|
# Check that output directory is empty
|
||||||
if os.path.isdir(output_directory) and no_compress and \
|
elif os.path.isdir(output_directory) and os.listdir(output_directory):
|
||||||
os.listdir(output_directory):
|
|
||||||
|
|
||||||
raise YunohostError('backup_output_directory_not_empty')
|
raise YunohostError('backup_output_directory_not_empty')
|
||||||
elif no_compress:
|
|
||||||
raise YunohostError('backup_output_directory_required')
|
|
||||||
|
|
||||||
# Define methods (retro-compat)
|
|
||||||
if not methods:
|
|
||||||
if no_compress:
|
|
||||||
methods = ['copy']
|
|
||||||
else:
|
|
||||||
methods = ['tar']
|
|
||||||
|
|
||||||
# If no --system or --apps given, backup everything
|
# If no --system or --apps given, backup everything
|
||||||
if system is None and apps is None:
|
if system is None and apps is None:
|
||||||
|
@ -2038,18 +2033,14 @@ def backup_create(name=None, description=None, methods=[],
|
||||||
# Create yunohost archives directory if it does not exists
|
# Create yunohost archives directory if it does not exists
|
||||||
_create_archive_dir()
|
_create_archive_dir()
|
||||||
|
|
||||||
# Prepare files to backup
|
# Initialize backup manager
|
||||||
if no_compress:
|
|
||||||
backup_manager = BackupManager(name, description,
|
|
||||||
work_dir=output_directory)
|
|
||||||
else:
|
|
||||||
backup_manager = BackupManager(name, description)
|
|
||||||
|
|
||||||
|
backup_manager = BackupManager(name, description, work_dir=output_directory)
|
||||||
for method in methods:
|
for method in methods:
|
||||||
backup_manager.methods += BackupMethod.create(method, backup_manager, repo=output_directory))
|
backup_manager.methods += BackupMethod.create(method, backup_manager, repo=output_directory))
|
||||||
|
|
||||||
|
|
||||||
# Add backup targets (system and apps)
|
# Add backup targets (system and apps)
|
||||||
|
|
||||||
backup_manager.set_system_targets(system)
|
backup_manager.set_system_targets(system)
|
||||||
backup_manager.set_apps_targets(apps)
|
backup_manager.set_apps_targets(apps)
|
||||||
|
|
||||||
|
|
|
@ -387,13 +387,13 @@ def test_backup_with_different_output_directory(mocker):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.clean_opt_dir
|
@pytest.mark.clean_opt_dir
|
||||||
def test_backup_with_no_compress(mocker):
|
def test_backup_using_copy_method(mocker):
|
||||||
|
|
||||||
# Create the backup
|
# Create the backup
|
||||||
with message(mocker, "backup_created"):
|
with message(mocker, "backup_created"):
|
||||||
backup_create(system=["conf_nginx"], apps=None,
|
backup_create(system=["conf_nginx"], apps=None,
|
||||||
output_directory="/opt/test_backup_output_directory",
|
output_directory="/opt/test_backup_output_directory",
|
||||||
no_compress=True,
|
methods=["copy"],
|
||||||
name="backup")
|
name="backup")
|
||||||
|
|
||||||
assert os.path.exists("/opt/test_backup_output_directory/info.json")
|
assert os.path.exists("/opt/test_backup_output_directory/info.json")
|
||||||
|
|
Loading…
Add table
Reference in a new issue