Merge branch 'fix/overeagerPreemptiveCache' into devel
Conflicts: src/octoprint/filemanager/storage.py src/octoprint/server/views.py
This commit is contained in:
commit
c2fc139b97
4 changed files with 16 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue