Fix cache invalidation on slicing API
Wasn't properly revalidating when an already registered slicer switched between unconfigured and configured. Also adjusted data format version tracking on files and slicing API to match.
This commit is contained in:
parent
7df78defb1
commit
468155c9c8
2 changed files with 17 additions and 5 deletions
|
|
@ -29,7 +29,7 @@ import threading
|
|||
_file_cache = dict()
|
||||
_file_cache_mutex = threading.RLock()
|
||||
|
||||
_FILES_DATA_VERSION = 1
|
||||
_DATA_FORMAT_VERSION = "v2"
|
||||
|
||||
def _clear_file_cache():
|
||||
with _file_cache_mutex:
|
||||
|
|
@ -73,7 +73,6 @@ def _create_etag(path, filter, recursive, lm=None):
|
|||
return None
|
||||
|
||||
hash = hashlib.sha1()
|
||||
hash.update(str(_FILES_DATA_VERSION))
|
||||
hash.update(str(lm))
|
||||
hash.update(str(filter))
|
||||
hash.update(str(recursive))
|
||||
|
|
@ -82,6 +81,8 @@ def _create_etag(path, filter, recursive, lm=None):
|
|||
# include sd data in etag
|
||||
hash.update(repr(sorted(printer.get_sd_files(), key=lambda x: x[0])))
|
||||
|
||||
hash.update(_DATA_FORMAT_VERSION) # increment version if we change the API format
|
||||
|
||||
return hash.hexdigest()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ from octoprint.settings import settings as s, valid_boolean_trues
|
|||
from octoprint.slicing import UnknownSlicer, SlicerNotConfigured, ProfileAlreadyExists, UnknownProfile, CouldNotDeleteProfile
|
||||
|
||||
|
||||
_DATA_FORMAT_VERSION = "v2"
|
||||
|
||||
|
||||
def _lastmodified(configured):
|
||||
if configured:
|
||||
slicers = slicingManager.configured_slicers
|
||||
|
|
@ -39,11 +42,19 @@ def _etag(configured, lm=None):
|
|||
hash.update(str(lm))
|
||||
|
||||
if configured:
|
||||
hash.update(repr(sorted(slicingManager.configured_slicers)))
|
||||
slicers = slicingManager.configured_slicers
|
||||
else:
|
||||
hash.update(repr(sorted(slicingManager.registered_slicers)))
|
||||
slicers = slicingManager.registered_slicers
|
||||
|
||||
hash.update("v2") # increment version if we change the API format
|
||||
default_slicer = s().get(["slicing", "defaultSlicer"])
|
||||
|
||||
for slicer in sorted(slicers):
|
||||
slicer_impl = slicingManager.get_slicer(slicer, require_configured=False)
|
||||
hash.update(slicer)
|
||||
hash.update(str(slicer_impl.is_slicer_configured()))
|
||||
hash.update(str(slicer == default_slicer))
|
||||
|
||||
hash.update(_DATA_FORMAT_VERSION) # increment version if we change the API format
|
||||
|
||||
return hash.hexdigest()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue