From cb8aa9b07c271df34170ee4f26a0364f8fe33dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 5 Jun 2023 11:57:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20swu:=20refuse=20OctoPrint=20upda?= =?UTF-8?q?te=20under=20Windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also improve error messaging in that regard (and fix some typo issues in an existing FAQ URL). Closes #4819 --- src/octoprint/plugins/softwareupdate/__init__.py | 9 +++++++++ .../softwareupdate/static/js/softwareupdate.js | 13 +++++++++++++ .../templates/softwareupdate_settings.jinja2 | 4 ++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index d271c1041..945199e60 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -9,6 +9,7 @@ import hashlib import logging import logging.handlers import os +import sys import threading import time from concurrent import futures @@ -1913,6 +1914,14 @@ class SoftwareUpdatePlugin( except Exception: self._logger.exception(f"Error while checking if {target} can be updated") update_possible = False + error = "update" + + if target == "octoprint" and sys.platform == "win32": + self._logger.info( + "OctoPrint is running on Windows, it cannot be updated through itself due to Windows' file locking behavior. Please update manually." + ) + update_possible = False + error = "windows" self._version_cache[target] = { "timestamp": time.time(), diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js index aba2cf5b7..a9098d576 100644 --- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js +++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js @@ -720,6 +720,19 @@ $(function () { "Unknown error while checking for update, please check the logs" ); } + case "update": { + return gettext( + "Unknown error while checking if update is possible, please check the logs" + ); + } + case "windows": { + return _.sprintf( + gettext( + 'Update not possible under Windows due to its strict file locking behaviour, please see the FAQ' + ), + {url: "https://faq.octoprint.org/update-not-possible-windows"} + ); + } default: { return ""; } diff --git a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 index 4080362ea..b6b2e3342 100644 --- a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 +++ b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 @@ -46,7 +46,7 @@ {% trans %}

- Please take a look at this FAQ entry on how to proceed. + Please take a look at this FAQ entry on how to proceed.

{% endtrans %}
{% trans %} @@ -115,7 +115,7 @@ {{ _('Installed:') }} {{ _('Available:') }} {{ _('Release Notes:') }} - + {{ _('Newer versions of this plugin are not compatible to this setup.') }}