diff --git a/src/octoprint/filemanager/storage.py b/src/octoprint/filemanager/storage.py index c506f1a9..bf0af565 100644 --- a/src/octoprint/filemanager/storage.py +++ b/src/octoprint/filemanager/storage.py @@ -500,7 +500,7 @@ class LocalFileStorage(StorageInterface): folder_path = os.path.join(path, name) if os.path.exists(folder_path): if not ignore_existing: - raise StorageError("{sanitized_foldername} does already exist in {virtual_path}".format(**locals()), code=StorageError.ALREADY_EXISTS) + raise StorageError("{name} does already exist in {path}".format(**locals()), code=StorageError.ALREADY_EXISTS) else: os.mkdir(folder_path) @@ -517,7 +517,7 @@ class LocalFileStorage(StorageInterface): if ".metadata.yaml" in contents: contents.remove(".metadata.yaml") if contents and not recursive: - raise StorageError("{sanitized_foldername} in {virtual_path} is not empty".format(**locals()), code=StorageError.NOT_EMPTY) + raise StorageError("{name} in {path} is not empty".format(**locals()), code=StorageError.NOT_EMPTY) import shutil shutil.rmtree(folder_path) diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index e7e99aa4..a653f409 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -771,6 +771,12 @@ class Server(object): additional_request_data = kwargs.get("_additional_request_data", dict()) kwargs = dict((k, v) for k, v in kwargs.items() if not k.startswith("_") and not k == "plugin") kwargs.update(additional_request_data) + + base_url = kwargs.get("base_url", "") + if not (base_url.startswith("http://") or base_url.startswith("https://")): + self._logger.info("Skipping preemptive cache entry with base url {}, neither http:// nor https:// and possibly broken".format(base_url)) + continue + try: if plugin: self._logger.info("Preemptively caching {} (plugin {}) for {!r}".format(route, plugin, kwargs)) diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py index 8c7c3a18..40087c3a 100644 --- a/src/octoprint/server/util/flask.py +++ b/src/octoprint/server/util/flask.py @@ -498,6 +498,12 @@ class PreemptiveCache(object): return matched, unmatched with self._lock: + if not self._log_access: + self._logger.debug( + "Not updating timestamp and counter for {} and {!r}, currently flagged as disabled".format(root, + data)) + return + cache_data = self.get_all_data() if not root in cache_data: @@ -519,12 +525,10 @@ class PreemptiveCache(object): to_persist["_timestamp"] = time.time() to_persist["_count"] = 1 self._logger.info("Adding entry for {} and {!r}".format(root, to_persist)) - elif self._log_access: + else: to_persist["_timestamp"] = time.time() to_persist["_count"] = to_persist.get("_count", 0) + 1 self._logger.debug("Updating timestamp and counter for {} and {!r}".format(root, data)) - else: - self._logger.debug("Not updating timestamp and counter for {} and {!r}, currently flagged as disabled".format(root, data)) self.set_data(root, [to_persist] + other) diff --git a/src/octoprint/server/views.py b/src/octoprint/server/views.py index feb6588f..d0b0e05f 100644 --- a/src/octoprint/server/views.py +++ b/src/octoprint/server/views.py @@ -88,7 +88,7 @@ def index(): _logger.exception("Error retrieving additional data for preemptive cache from plugin {}".format(key)) def unless(): - disabled_for_root = request.url_root in settings().get(["server", "preemptiveCache", "exceptions"]) + disabled_for_root = request.url_root in settings().get(["server", "preemptiveCache", "exceptions"]) or not (request.url_root.startswith("http://") or request.url_root.startswith("https://"))) if callable(additional_unless): return disabled_for_root or additional_unless() else: