diff --git a/.versioneer-lookup b/.versioneer-lookup index ed6f19dec..1e8c5e63d 100644 --- a/.versioneer-lookup +++ b/.versioneer-lookup @@ -24,10 +24,10 @@ maintenance 1.3.11 e14c00f135bf2a955e54ac3f0a2928d8440055d2 pep440-dev fix/.* 1.3.11 e14c00f135bf2a955e54ac3f0a2928d8440055d2 pep440-dev improve/.* 1.3.11 e14c00f135bf2a955e54ac3f0a2928d8440055d2 pep440-dev -# staging/maintenance is currently the branch for preparation of 1.3.10rc4 +# staging/maintenance is currently the branch for preparation of 1.3.10rc5 # so is regressionfix/... -staging/maintenance 1.3.10rc4 b01e327f9d89fc28646e57b709e12ff0574c6ffb pep440-dev -regressionfix/.* 1.3.10rc4 b01e327f9d89fc28646e57b709e12ff0574c6ffb pep440-dev +staging/maintenance 1.3.10rc5 e628aedbc11e2ef03ba4172b93e5be2a892b955b pep440-dev +regressionfix/.* 1.3.10rc5 e628aedbc11e2ef03ba4172b93e5be2a892b955b pep440-dev # every other branch is a development branch and thus gets resolved to 1.4.0-dev for now .* 1.4.0 7f5d03d0549bcbd26f40e7e4a3297ea5204fb1cc pep440-dev diff --git a/CHANGELOG.md b/CHANGELOG.md index a687390b1..9172b05b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # OctoPrint Changelog +## 1.3.10rc4 (2018-12-03) + +### Improvements + + * Backup: Exclude `generated`, `logs` and `watched` folders from backup + * Backup: Use base version for version check on restore + +### Bug fixes + + * [#2920](https://github.com/foosel/OctoPrint/issues/2920) - Backup: Fix wrong compatibility check logic in plugin install during restore + * Backup: Disable restore on Windows servers where it's not supported thanks to the Windows file system + * Backup: Fix reporting of restore failure due to version mismatch or other cases of an invalid backup + * Backup: Fix feedback in UI during restore, start feedback right on upload of backup + * Printer Safety: Fix localization of warning message + +### Unreproduced issues + +The following issues were reported in RC1 or RC2 but so far have been unreproduced and further data to analyse them is still missing. If you encounter any of them please report back with a [fully filled out issue template](https://github.com/foosel/OctoPrint/blob/master/CONTRIBUTING.md#what-should-i-include-in-a-bug-report): + + * [Not possible to complete Anonymous Usage Tracking setup wizard](https://discourse.octoprint.org/t/anonymous-usage-setup/5151) + * ["temperature changes doesn't work"](https://github.com/foosel/OctoPrint/issues/2889#issuecomment-441449215) + +### Special thanks to all the contributors! + +Special thanks to everyone who contributed to this release candidate and provided full, analysable bug reports. + +### More information + + * [Commits](https://github.com/foosel/OctoPrint/compare/1.3.10rc3...1.3.10rc4) + +## 1.3.10rc3 (2018-11-28) + ### Improvements * More resilience against third party plugins that happily block or kill important startup threads diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py index 8e8e14279..b00f5faf2 100644 --- a/src/octoprint/plugins/backup/__init__.py +++ b/src/octoprint/plugins/backup/__init__.py @@ -11,7 +11,8 @@ from octoprint.plugin.core import FolderOrigin from octoprint.server import admin_permission, NO_CONTENT from octoprint.server.util.flask import restricted_access from octoprint.util import is_hidden_path -from octoprint.util.version import get_octoprint_version_string, get_octoprint_version, get_comparable_version +from octoprint.util.version import get_octoprint_version_string, get_octoprint_version, get_comparable_version, is_octoprint_compatible +from octoprint.util.platform import is_os_compatible from octoprint.util.pip import LocalPipCaller try: @@ -83,7 +84,8 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, unknown_plugins = self._get_unknown_plugins() return flask.jsonify(backups=backups, backup_in_progress=len(self._in_progress) > 0, - unknown_plugins=unknown_plugins) + unknown_plugins=unknown_plugins, + restore_supported=is_os_compatible(["!windows"])) @octoprint.plugin.BlueprintPlugin.route("/unknown_plugins", methods=["GET"]) @admin_permission.require(403) @@ -184,6 +186,9 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, @admin_permission.require(403) @restricted_access def perform_restore(self): + if not is_os_compatible(["!windows"]): + return flask.make_response(u"Invalid request, the restores are not supported on the underlying operating system", 400) + input_name = "file" input_upload_path = input_name + "." + self._settings.global_get(["server", "uploads", "pathSuffix"]) @@ -212,8 +217,8 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, self._send_client_message("logline", dict(line=line, type="stdout")) for plugin in plugins: - octoprint_compatible = plugin["compatibility"]["octoprint"] - os_compatible = plugin["compatibility"]["os"] + octoprint_compatible = is_octoprint_compatible(*plugin["compatibility"]["octoprint"]) + os_compatible = is_os_compatible(plugin["compatibility"]["os"]) compatible = octoprint_compatible and os_compatible if not compatible: if not octoprint_compatible and not os_compatible: @@ -260,9 +265,12 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, def on_restore_done(path): self._send_client_message("restore_done") - def on_restore_failed(path, exc_info): + def on_restore_failed(path): self._send_client_message("restore_failed") + def on_invalid_backup(line): + on_log_error(line) + archive = tempfile.NamedTemporaryFile(delete=False) archive.close() shutil.copy(path, archive.name) @@ -276,6 +284,7 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, datafolder=self.get_plugin_data_folder(), on_install_plugins=on_install_plugins, on_report_unknown_plugins=on_report_unknown_plugins, + on_invalid_backup=on_invalid_backup, on_log_progress=on_log_progress, on_log_error=on_log_error, on_restore_start=on_restore_start, @@ -384,8 +393,8 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, click.echo(u"\t{}".format(line)) for plugin in plugins: - octoprint_compatible = plugin["compatibility"]["octoprint"] - os_compatible = plugin["compatibility"]["os"] + octoprint_compatible = is_octoprint_compatible(*plugin["compatibility"]["octoprint"]) + os_compatible = is_os_compatible(plugin["compatibility"]["os"]) compatible = octoprint_compatible and os_compatible if not compatible: if not octoprint_compatible and not os_compatible: @@ -432,7 +441,8 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, on_install_plugins=on_install_plugins, on_report_unknown_plugins=on_report_unknown_plugins, on_log_progress=on_log_progress, - on_log_error=on_log_error): + on_log_error=on_log_error, + on_invalid_backup=on_log_error): click.echo(u"Restored from {}".format(path)) else: click.echo(u"Restoring from {} failed".format(path), err=True) @@ -634,6 +644,10 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, for folder in default_settings["folder"].keys(): if folder in exclude: continue + + if folder in ("generated", "logs", "watched",): + continue + add_to_zip(settings.global_get_basefolder(folder), "basedir/" + folder.replace("_", "/"), ignored=[own_folder,]) @@ -682,6 +696,13 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, on_restore_start=None, on_restore_done=None, on_restore_failed=None): + if not is_os_compatible(["!windows"]): + if callable(on_log_error): + on_log_error(u"Restore is not supported on this operating system") + if callable(on_restore_failed): + on_restore_failed(path) + return False + restart_command = settings.global_get(["server", "commands", "serverRestartCommand"]) basedir = settings._basedir @@ -705,15 +726,19 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, except KeyError: if callable(on_invalid_backup): on_invalid_backup(u"Not an OctoPrint backup, lacks metadata.json") + if callable(on_restore_failed): + on_restore_failed(path) return False metadata_bytes = zip.read(metadata_zipinfo) metadata = json.loads(metadata_bytes) - backup_version = get_comparable_version(metadata["version"]) - if backup_version > get_octoprint_version(): + backup_version = get_comparable_version(metadata["version"], base=True) + if backup_version > get_octoprint_version(base=True): if callable(on_invalid_backup): on_invalid_backup(u"Backup is from a newer version of OctoPrint and cannot be applied") + if callable(on_restore_failed): + on_restore_failed(path) return False # unzip to temporary folder @@ -732,6 +757,8 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, if not os.path.exists(configfile): if callable(on_invalid_backup): on_invalid_backup(u"Backup lacks config.yaml") + if callable(on_restore_failed): + on_restore_failed(path) return False import yaml @@ -744,6 +771,8 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, if not os.path.exists(userfile): if callable(on_invalid_backup): on_invalid_backup(u"Backup lacks users.yaml") + if callable(on_restore_failed): + on_restore_failed(path) return False if callable(on_log_progress): @@ -835,7 +864,7 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, if callable(on_log_error): on_log_error(u"Error while running restore", exc_info=exc_info) if callable(on_restore_failed): - on_restore_failed(path, exc_info) + on_restore_failed(path) finally: del exc_info return False @@ -852,6 +881,9 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, if callable(on_log_progress): on_log_progress(u"Restarting...") + if callable(on_restore_done): + on_restore_done(path) + try: sarge.run(restart_command, async_=True) except: @@ -861,8 +893,9 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, on_log_error(u"Please restart OctoPrint manually") return False - if callable(on_restore_done): - on_restore_done(path) + else: + if callable(on_restore_done): + on_restore_done(path) return True diff --git a/src/octoprint/plugins/backup/static/js/backup.js b/src/octoprint/plugins/backup/static/js/backup.js index d54916015..26929ec57 100644 --- a/src/octoprint/plugins/backup/static/js/backup.js +++ b/src/octoprint/plugins/backup/static/js/backup.js @@ -27,6 +27,7 @@ $(function() { self.excludeFromBackup = ko.observableArray([]); self.backupInProgress = ko.observable(false); + self.restoreSupported = ko.observable(true); self.backupUploadButton = $("#settings-backup-upload"); self.backupUploadData = undefined; @@ -66,6 +67,7 @@ $(function() { self.fromResponse = function(response) { self.backups.updateItems(response.backups); self.unknownPlugins(response.unknown_plugins); + self.restoreSupported(response.restore_supported); }; self.createBackup = function() { @@ -88,7 +90,15 @@ $(function() { }; self.restoreBackup = function(backup) { + if (!self.restoreSupported()) return; + var perform = function() { + self.restoreInProgress(true); + self.loglines.removeAll(); + self.loglines.push({line: "Preparing to restore...", stream: "message"}); + self.loglines.push({line: " ", stream: "message"}); + self.restoreDialog.modal({keyboard: false, backdrop: "static", show: true}); + OctoPrint.plugins.backup.restoreBackup(backup); }; showConfirmationDialog(_.sprintf(gettext("You are about to restore the backup file \"%(name)s\". This cannot be undone."), {name: backup}), @@ -99,6 +109,12 @@ $(function() { if (self.backupUploadData === undefined) return; var perform = function() { + self.restoreInProgress(true); + self.loglines.removeAll(); + self.loglines.push({line: "Uploading backup, this can take a while. Please wait...", stream: "message"}); + self.loglines.push({line: " ", stream: "message"}); + self.restoreDialog.modal({keyboard: false, backdrop: "static", show: true}); + self.backupUploadData.submit(); }; showConfirmationDialog(_.sprintf(gettext("You are about to upload and restore the backup file \"%(name)s\". This cannot be undone."), {name: self.backupUploadName()}), @@ -171,11 +187,8 @@ $(function() { hide: false }); } else if (data.type === "restore_started") { - self.restoreInProgress(true); - self.loglines.removeAll(); self.loglines.push({line: gettext("Restoring from backup..."), stream: "message"}); self.loglines.push({line: " ", stream: "message"}); - self.restoreDialog.modal({keyboard: false, backdrop: "static", show: true}); } else if (data.type === "restore_failed") { self.loglines.push({line: " ", stream: "message"}); self.loglines.push({line: gettext("Restore failed! Check the above output and octoprint.log for reasons as to why."), stream: "error"}); diff --git a/src/octoprint/plugins/backup/templates/backup_settings.jinja2 b/src/octoprint/plugins/backup/templates/backup_settings.jinja2 index 2d0e5e57f..e9546adb2 100644 --- a/src/octoprint/plugins/backup/templates/backup_settings.jinja2 +++ b/src/octoprint/plugins/backup/templates/backup_settings.jinja2 @@ -46,7 +46,7 @@ -  |  |  +  |  |  @@ -91,30 +91,36 @@ -

{{ _('Restore from uploaded backup') }}

+
+

{{ _('Restore from uploaded backup') }}

-

{{ _('Restore settings & files from an uploaded backup archive.') }}

+

{{ _('Restore settings & files from an uploaded backup archive.') }}

-
-
- -
-
- - {{ _('Browse...') }} - - - + +
+ +
+
+ + {{ _('Browse...') }} + + + +
-
-
-
- +
+
+ +
-
- + +
+ +
+ {{ _('Please note that the operating system that this OctoPrint server is running on does not support automatically restoring backups. You will have to restore your backups manually for now.', url='https://faq.octoprint.org/manual-restore') }} +