Backups: minor adaption of upload file size warning

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Michael Pimmer 2018-11-14 16:30:40 +00:00 committed by James Valleroy
parent c988d468f2
commit 9cba16e0d0
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 14 additions and 5 deletions

View File

@ -32,9 +32,11 @@
You can choose the apps you wish to import after uploading a backup file.
{% endblocktrans %}
</p>
<div class="alert alert-info" role="alert">
{% trans "Free disk space" %}: {{ free_space }}<br />
{% trans "Make sure the uploaded file is smaller than that." %}
<div class="alert alert-warning" role="alert">
{% blocktrans trimmed %}
WARNING: You have {{ max_filesize }} available to restore a backup.<br />
Exceeding this limit can leave your {{ box_name }} unusable.
{% endblocktrans %}
</div>
<form class="form" enctype="multipart/form-data" method="post">

View File

@ -151,8 +151,15 @@ class UploadArchiveView(SuccessMessageMixin, FormView):
except (PlinthError, PermissionError):
logger.error('Error getting information about root partition.')
else:
context['free_space'] = storage.format_bytes(
disk_info["free_bytes"])
# The maximum file size that can be uploaded and restored is at
# most half of the available disk space:
# - Django stores uploaded files that do not fit into memory to
# disk (/tmp/). These are only copied by form_valid() after
# the upload is finished.
# - 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)
return context
def form_valid(self, form):