diff --git a/actions/snapshot b/actions/snapshot index 2b0bf3271..c8e0e21b9 100755 --- a/actions/snapshot +++ b/actions/snapshot @@ -254,7 +254,7 @@ def subcommand_get_config(_): def subcommand_migrate(_): """Migrate existing user configuration for snapshots to the new configuration format. - Add in version 4 of the snapshots module. + Added in version 4 of the snapshots module. This command will not check or perform first setup steps. """ config = _get_config() diff --git a/plinth/modules/snapshot/__init__.py b/plinth/modules/snapshot/__init__.py index 6946a046c..0b96fcbca 100644 --- a/plinth/modules/snapshot/__init__.py +++ b/plinth/modules/snapshot/__init__.py @@ -117,8 +117,8 @@ def get_configuration(): get_max_from_range('TIMELINE_LIMIT_MONTHLY'), 'yearly_limit': get_max_from_range('TIMELINE_LIMIT_YEARLY'), - 'number_min_age': - round(int(output['NUMBER_MIN_AGE']) / 86400), + 'free_space': + output['FREE_LIMIT'], } diff --git a/plinth/modules/snapshot/forms.py b/plinth/modules/snapshot/forms.py index c3657129f..279e7c2cb 100644 --- a/plinth/modules/snapshot/forms.py +++ b/plinth/modules/snapshot/forms.py @@ -23,17 +23,23 @@ from django.utils.translation import ugettext_lazy as _ class SnapshotForm(forms.Form): - enable_timeline_snapshots = forms.ChoiceField( - label=_('Timeline Snapshots'), help_text=_( - 'Enable or disable timeline snapshots ' - '(hourly, daily, monthly and yearly).'), - choices=[('yes', 'Enabled'), ('no', 'Disabled')]) + free_space = forms.ChoiceField( + label=_('Free Space'), + help_text=_('Maintain this percentage of free space on the disk. ' + 'The default value is 30%.'), + choices=[(i / 100, i) for i in range(10, 70, 10)]) enable_software_snapshots = forms.ChoiceField( label=_('Software Installation Snapshots'), help_text=_( 'Enable or disable snapshots before and after software ' 'installation'), choices=[('yes', 'Enabled'), ('no', 'Disabled')]) + enable_timeline_snapshots = forms.ChoiceField( + label=_('Timeline Snapshots'), + help_text=_('Enable or disable timeline snapshots ' + '(hourly, daily, monthly and yearly).'), + choices=[('yes', 'Enabled'), ('no', 'Disabled')]) + hourly_limit = forms.IntegerField( label=_('Hourly Snapshots Limit'), min_value=0, help_text=_('Keep a maximum of this many hourly snapshots.')) @@ -51,12 +57,6 @@ class SnapshotForm(forms.Form): help_text=_('Keep a maximum of this many monthly snapshots.')) yearly_limit = forms.IntegerField( - label=_('Yearly Snapshots Limit'), min_value=0, help_text=_( - 'Keep a maximum of this many yearly snapshots. ' - 'The default is 0 (disabled).')) - - number_min_age = forms.IntegerField( - label=_('Delete Software Snapshots older than (days)'), min_value=0, - help_text=_( - 'Software snapshots older than this will be deleted. ' - 'This does not limit the number of software snapshots created.')) + label=_('Yearly Snapshots Limit'), min_value=0, + help_text=_('Keep a maximum of this many yearly snapshots. ' + 'The default value is 0 (disabled).')) diff --git a/plinth/modules/snapshot/views.py b/plinth/modules/snapshot/views.py index 75669a733..8d14d22e2 100644 --- a/plinth/modules/snapshot/views.py +++ b/plinth/modules/snapshot/views.py @@ -105,8 +105,6 @@ def update_configuration(request, old_status, new_status): else: return None - new_status['number_min_age'] = int(new_status['number_min_age']) * 86400 - config = filter( None, map(make_config, [ @@ -116,7 +114,7 @@ def update_configuration(request, old_status, new_status): ('weekly_limit', 'TIMELINE_LIMIT_WEEKLY={}'), ('monthly_limit', 'TIMELINE_LIMIT_MONTHLY={}'), ('yearly_limit', 'TIMELINE_LIMIT_YEARLY={}'), - ('number_min_age', 'NUMBER_MIN_AGE={}'), + ('free_space', 'FREE_LIMIT={}'), ])) if old_status['enable_software_snapshots'] != new_status['enable_software_snapshots']: