diff --git a/plinth/modules/samba/tests/test_views.py b/plinth/modules/samba/tests/test_views.py index 2bf5ae490..ed1919470 100644 --- a/plinth/modules/samba/tests/test_views.py +++ b/plinth/modules/samba/tests/test_views.py @@ -27,6 +27,14 @@ DISKS = [{ 'percent_used': 63, 'size_str': '9.5 GiB', 'used_str': '5.7 GiB' +}, { + 'device': '/dev/sda2', + 'label': '', + 'filesystem_type': 'vfat', + 'mount_point': '/boot/efi', + 'percent_used': 50, + 'size_str': '150 MiB', + 'used_str': '75 MiB' }] SHARES = [ @@ -96,7 +104,7 @@ def test_samba_shares_view(rf): view = views.SambaAppView.as_view() response, _ = make_request(rf.get(''), view) - assert response.context_data['disks'] == DISKS + assert response.context_data['disks'] == [DISKS[0]] assert response.context_data['shared_mounts'] == { '/': ['open', 'home'], '/media/root/otherdisk': ['open'] diff --git a/plinth/modules/samba/views.py b/plinth/modules/samba/views.py index 3de708c44..a1b4786ed 100644 --- a/plinth/modules/samba/views.py +++ b/plinth/modules/samba/views.py @@ -12,7 +12,6 @@ from django.shortcuts import redirect from django.urls import reverse from django.utils.translation import ugettext as _ from django.views.decorators.http import require_POST - from plinth import views from plinth.errors import ActionError from plinth.modules import samba, storage @@ -20,6 +19,15 @@ from plinth.modules import samba, storage logger = logging.getLogger(__name__) +def get_share_mounts(): + """Return list of mount points.""" + ignore_points = ('/boot', '/boot/efi', '/boot/firmware', '/.snapshots') + return [ + mount for mount in storage.get_mounts() + if mount['mount_point'] not in ignore_points + ] + + class SambaAppView(views.AppView): """Samba sharing basic configuration.""" app_id = 'samba' @@ -28,7 +36,7 @@ class SambaAppView(views.AppView): def get_context_data(self, *args, **kwargs): """Return template context data.""" context = super().get_context_data(*args, **kwargs) - disks = storage.get_mounts() + disks = get_share_mounts() shares = samba.get_shares() for disk in disks: