mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-18 08:33:41 +00:00
storage, backups: Minor styling and yapf fixes
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
9e316baa99
commit
41d9419ddd
@ -157,7 +157,8 @@ 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)
|
||||
disk_info['free_bytes'] / 2)
|
||||
|
||||
return context
|
||||
|
||||
def form_valid(self, form):
|
||||
@ -242,12 +243,13 @@ class RestoreArchiveView(BaseRestoreView):
|
||||
|
||||
class DownloadArchiveView(View):
|
||||
"""View to export and download an archive as stream."""
|
||||
|
||||
def get(self, request, uuid, name):
|
||||
repository = get_repository(uuid)
|
||||
filename = "%s.tar.gz" % name
|
||||
|
||||
response = StreamingHttpResponse(repository.get_zipstream(name),
|
||||
content_type="application/x-gzip")
|
||||
response = StreamingHttpResponse(
|
||||
repository.get_zipstream(name), content_type='application/x-gzip')
|
||||
response['Content-Disposition'] = 'attachment; filename="%s"' % \
|
||||
filename
|
||||
return response
|
||||
@ -293,8 +295,9 @@ class RemoveRepositoryView(SuccessMessageMixin, TemplateView):
|
||||
"""Delete the archive."""
|
||||
repository = SshBorgRepository(uuid, automount=False)
|
||||
repository.remove_repository()
|
||||
messages.success(request, _('Repository removed. The remote backup '
|
||||
'itself was not deleted.'))
|
||||
messages.success(
|
||||
request,
|
||||
_('Repository removed. The remote backup itself was not deleted.'))
|
||||
return redirect('backups:index')
|
||||
|
||||
|
||||
|
||||
@ -153,9 +153,9 @@ def get_disk_info(mount_point):
|
||||
free_bytes = list_root[0]['free']
|
||||
free_gib = free_bytes / (1024**3)
|
||||
return {
|
||||
"percent_used": percent_used,
|
||||
"free_bytes": free_bytes,
|
||||
"free_gib": free_gib
|
||||
'percent_used': percent_used,
|
||||
'free_bytes': free_bytes,
|
||||
'free_gib': free_gib
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -105,12 +105,12 @@ def warn_about_low_disk_space(request):
|
||||
# Translators: xgettext:no-python-format
|
||||
_('Warning: Low space on system partition ({percent_used}% used, '
|
||||
'{free_space} free).'),
|
||||
percent_used=root_info["percent_used"],
|
||||
free_space=storage.format_bytes(root_info["free_bytes"]))
|
||||
percent_used=root_info['percent_used'],
|
||||
free_space=storage.format_bytes(root_info['free_bytes']))
|
||||
|
||||
if root_info["percent_used"] > 90 or root_info["free_gib"] < 1:
|
||||
if root_info['percent_used'] > 90 or root_info['free_gib'] < 1:
|
||||
messages.error(request, message)
|
||||
elif root_info["percent_used"] > 75 or root_info["free_gib"] < 2:
|
||||
elif root_info['percent_used'] > 75 or root_info['free_gib'] < 2:
|
||||
messages.warning(request, message)
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user