From 3940868f2142793202b890ecd02218dfa5d197ff Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Mon, 18 Jun 2018 16:00:12 +0530 Subject: [PATCH] first-setup: Automatically expand root partition - Show expansion option in the UI only if the partition expansion failed during first setup. Signed-off-by: Joseph Nuthalapati Reviewed-by: James Valleroy --- plinth/modules/storage/__init__.py | 12 +++++++++++- plinth/modules/storage/templates/storage.html | 14 +------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/plinth/modules/storage/__init__.py b/plinth/modules/storage/__init__.py index 5ba284447..75ad6bccb 100644 --- a/plinth/modules/storage/__init__.py +++ b/plinth/modules/storage/__init__.py @@ -27,7 +27,7 @@ from django.utils.translation import ugettext_lazy as _ from plinth import actions from plinth.menu import main_menu -version = 1 +version = 2 name = _('Storage') @@ -39,6 +39,8 @@ logger = logging.getLogger(__name__) manual_page = 'Storage' +is_essential = True + def init(): """Intialize the module.""" @@ -164,3 +166,11 @@ def format_bytes(size): size /= 1024**4 return _('{disk_size:.1f} TiB').format(disk_size=size) + + +def setup(helper, old_version=None): + """Expand root parition on first setup.""" + disks = get_disks() + root_device = get_root_device(disks) + if is_expandable(root_device): + expand_partition(root_device) diff --git a/plinth/modules/storage/templates/storage.html b/plinth/modules/storage/templates/storage.html index ab65cc12e..69b06b2da 100644 --- a/plinth/modules/storage/templates/storage.html +++ b/plinth/modules/storage/templates/storage.html @@ -83,8 +83,8 @@ -

{% trans "Partition Expansion" %}

{% if expandable_root_size %} +

{% trans "Partition Expansion" %}

{% blocktrans trimmed %} There is {{ expandable_root_size }} of unallocated space @@ -98,18 +98,6 @@ role="button"> {% trans "Expand Root Partition" %}

- {% else %} -

- {% blocktrans trimmed %} - There is no unallocated space after your root partition. - There is no need to expand it. - {% endblocktrans %} -

-

- - {% trans "Expand Root Partition" %} -

{% endif %} {% endblock %}