Backups: minor adaption of upload file size warning

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Michael Pimmer authored and James Valleroy committed 2018-11-17 09:00:46 -05:00
1 parent c988d468f2
commit 9cba16e0d0
2 files changed
+14 -5

No files matched your search

@@ -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">
+9 -2
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):