Merge branch 'maintenance' into devel
Conflicts: src/octoprint/server/__init__.py src/octoprint/server/util/flask.py src/octoprint/server/views.py
This commit is contained in:
commit
f93212b06d
3 changed files with 6 additions and 21 deletions
|
|
@ -765,11 +765,11 @@ class Server(object):
|
|||
|
||||
headers = kwargs.get("headers", dict())
|
||||
headers["X-Force-View"] = plugin if plugin else "_default"
|
||||
headers["X-Preemptive-Record"] = "no"
|
||||
kwargs["headers"] = headers
|
||||
|
||||
builder = EnvironBuilder(**kwargs)
|
||||
with preemptive_cache.disable_access_logging():
|
||||
app(builder.get_environ(), lambda *a, **kw: None)
|
||||
app(builder.get_environ(), lambda *a, **kw: None)
|
||||
except:
|
||||
self._logger.exception("Error while trying to preemptively cache {} for {!r}".format(route, kwargs))
|
||||
|
||||
|
|
|
|||
|
|
@ -403,11 +403,8 @@ class PreemptiveCache(object):
|
|||
self.environment = None
|
||||
|
||||
self._logger = logging.getLogger(__name__ + "." + self.__class__.__name__)
|
||||
self._log_access = True
|
||||
|
||||
self._lock = threading.RLock()
|
||||
self._log_lock = threading.RLock()
|
||||
self._environment_lock = threading.RLock()
|
||||
|
||||
def record(self, data, unless=None, root=None):
|
||||
if callable(unless) and unless():
|
||||
|
|
@ -441,13 +438,6 @@ class PreemptiveCache(object):
|
|||
|
||||
return False
|
||||
|
||||
@contextlib.contextmanager
|
||||
def disable_access_logging(self):
|
||||
with self._log_lock:
|
||||
self._log_access = False
|
||||
yield
|
||||
self._log_access = True
|
||||
|
||||
def clean_all_data(self, cleanup_function):
|
||||
assert callable(cleanup_function)
|
||||
|
||||
|
|
@ -508,13 +498,6 @@ class PreemptiveCache(object):
|
|||
self.set_all_data(all_data)
|
||||
|
||||
def add_data(self, root, data):
|
||||
with self._log_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
|
||||
|
||||
def split_matched_and_unmatched(entry, entries):
|
||||
matched = []
|
||||
unmatched = []
|
||||
|
|
|
|||
|
|
@ -42,10 +42,12 @@ def _preemptive_unless(base_url=None, additional_unless=None):
|
|||
or base_url in settings().get(["server", "preemptiveCache", "exceptions"]) \
|
||||
or not (base_url.startswith("http://") or base_url.startswith("https://"))
|
||||
|
||||
recording_disabled = request.headers.get("X-Preemptive-Record", "yes") == "no"
|
||||
|
||||
if callable(additional_unless):
|
||||
return disabled_for_root or additional_unless()
|
||||
return recording_disabled or disabled_for_root or additional_unless()
|
||||
else:
|
||||
return disabled_for_root
|
||||
return recording_disabled or disabled_for_root
|
||||
|
||||
def _preemptive_data(key, path=None, base_url=None, data=None, additional_request_data=None):
|
||||
if path is None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue