diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py index bd3e73ab8..85453b664 100644 --- a/src/octoprint/plugins/backup/__init__.py +++ b/src/octoprint/plugins/backup/__init__.py @@ -51,12 +51,15 @@ from flask_babel import gettext from octoprint.plugins.pluginmanager import DEFAULT_PLUGIN_REPOSITORY from octoprint.settings import valid_boolean_trues +from octoprint.util import get_formatted_size from octoprint.util.text import sanitize UNKNOWN_PLUGINS_FILE = "unknown_plugins_from_restore.json" BACKUP_DATE_TIME_FMT = "%Y%m%d-%H%M%S" +MAX_UPLOAD_SIZE = 1024 * 1024 * 1024 # 1GB + class BackupPlugin( octoprint.plugin.SettingsPlugin, @@ -124,6 +127,12 @@ class BackupPlugin( {"type": "wizard", "name": gettext("Restore Backup?")}, ] + def get_template_vars(self): + return { + "max_upload_size": MAX_UPLOAD_SIZE, + "max_upload_size_str": get_formatted_size(MAX_UPLOAD_SIZE), + } + ##~~ BlueprintPlugin @octoprint.plugin.BlueprintPlugin.route("/", methods=["GET"]) @@ -137,6 +146,7 @@ class BackupPlugin( backup_in_progress=len(self._in_progress) > 0, unknown_plugins=unknown_plugins, restore_supported=self._restore_supported(self._settings), + max_upload_size=MAX_UPLOAD_SIZE, ) @octoprint.plugin.BlueprintPlugin.route("/unknown_plugins", methods=["GET"]) @@ -391,8 +401,8 @@ class BackupPlugin( ] def bodysize_hook(self, current_max_body_sizes, *args, **kwargs): - # max upload size of 1GB for the restore endpoint - return [("POST", r"/restore", 1024 * 1024 * 1024)] + # max upload size for the restore endpoint + return [("POST", r"/restore", MAX_UPLOAD_SIZE)] # Exported plugin helpers def create_backup_helper(self, exclude=None, filename=None): diff --git a/src/octoprint/plugins/backup/static/js/backup.js b/src/octoprint/plugins/backup/static/js/backup.js index 5f1894efd..436f699d9 100644 --- a/src/octoprint/plugins/backup/static/js/backup.js +++ b/src/octoprint/plugins/backup/static/js/backup.js @@ -27,10 +27,15 @@ $(function () { self.excludeFromBackup = ko.observableArray([]); self.backupInProgress = ko.observable(false); self.restoreSupported = ko.observable(true); + self.maxUploadSize = ko.observable(0); self.backupUploadData = undefined; self.backupUploadName = ko.observable(); + self.isAboveUploadSize = function (data) { + return data.size > self.maxUploadSize(); + }; + var backupFileuploadOptions = { dataType: "json", maxNumberOfFiles: 1, @@ -70,6 +75,7 @@ $(function () { self.backups.updateItems(response.backups); self.unknownPlugins(response.unknown_plugins); self.restoreSupported(response.restore_supported); + self.maxUploadSize(response.max_upload_size); }; self.createBackup = function () { diff --git a/src/octoprint/plugins/backup/templates/backup_settings.jinja2 b/src/octoprint/plugins/backup/templates/backup_settings.jinja2 index d6fdede80..50077d250 100644 --- a/src/octoprint/plugins/backup/templates/backup_settings.jinja2 +++ b/src/octoprint/plugins/backup/templates/backup_settings.jinja2 @@ -45,7 +45,7 @@
+ {{ _("Note:") }} + {% trans marker="" %} + OctoPrint currently only allows uploading backups of a maximum size of + {{ plugin_backup_max_upload_size_str }} via the UI. Backups larger than this can only be restored by command line, + or by adjusting the size by removing large contents (like timelapses) from the + zip prior to uploading. Backups exceeding this size limit are marked with a + {{ marker }} up there. + {% endtrans %} +
+ {{ _("Note:") }} + {% trans marker="!" %} + OctoPrint currently only allows uploading backups of a maximum size of + {{ plugin_backup_max_upload_size_str }} via the UI. Backups larger than this can only be restored by command line, + or by adjusting the size by removing large contents (like timelapses) from the + zip prior to uploading. Backups exceeding this size limit are marked with a + {{ marker }} up there. + {% endtrans %} +
{{ _('There are no backups yet.') }}