diff --git a/plinth/modules/backups/views.py b/plinth/modules/backups/views.py index 4dc6d3bf9..65b9aafc0 100644 --- a/plinth/modules/backups/views.py +++ b/plinth/modules/backups/views.py @@ -107,7 +107,7 @@ class UploadArchiveView(SuccessMessageMixin, FormView): context = super().get_context_data(**kwargs) context['title'] = _('Upload and restore a backup') try: - disk_info = storage.get_disk_info('/') + mount_info = storage.get_mount_info('/') except PlinthError as exception: logger.exception( 'Error getting information about root partition: %s', @@ -121,7 +121,7 @@ class UploadArchiveView(SuccessMessageMixin, FormView): # - For restoring it's highly advisable to have at least as much # free disk space as the file size. context['max_filesize'] = storage.format_bytes( - disk_info['free_bytes'] / 2) + mount_info['free_bytes'] / 2) return context @@ -164,6 +164,7 @@ class BaseRestoreView(SuccessMessageMixin, FormView): class RestoreFromUploadView(BaseRestoreView): """View to restore files from an (uploaded) exported archive.""" + def get(self, *args, **kwargs): path = self.request.session.get(SESSION_PATH_VARIABLE) if not os.path.isfile(path): @@ -193,6 +194,7 @@ class RestoreFromUploadView(BaseRestoreView): class RestoreArchiveView(BaseRestoreView): """View to restore files from an archive.""" + def _get_included_apps(self): """Save some data used to instantiate the form.""" name = unquote(self.kwargs['name']) @@ -210,6 +212,7 @@ class RestoreArchiveView(BaseRestoreView): class DownloadArchiveView(View): """View to export and download an archive as stream.""" + def get(self, request, uuid, name): repository = get_instance(uuid) filename = f'{name}.tar.gz' diff --git a/plinth/modules/storage/__init__.py b/plinth/modules/storage/__init__.py index ac1c21fbc..facb5d0b9 100644 --- a/plinth/modules/storage/__init__.py +++ b/plinth/modules/storage/__init__.py @@ -156,10 +156,12 @@ def get_filesystem_type(mount_point='/'): raise ValueError('No such mount point') -def get_disk_info(mount_point): - """Get information about the free space of a drive""" - disks = get_disks() - list_root = [disk for disk in disks if mount_point in disk['mount_points']] +def get_mount_info(mount_point): + """Get information about the free space of a mount point.""" + mounts = get_mounts() + list_root = [ + mount for mount in mounts if mount_point == mount['mount_point'] + ] if not list_root: raise PlinthError('Mount point {} not found.'.format(mount_point)) @@ -289,7 +291,7 @@ def warn_about_low_disk_space(request): from plinth.notification import Notification try: - root_info = get_disk_info('/') + root_info = get_mount_info('/') except PlinthError: return