Skip to content

Commit

Permalink
Include the version in the cached definitions path
Browse files Browse the repository at this point in the history
This ensures we do not try to load old cache files when a newer version
is used, or the other way around.

Fixes CURA-2832
  • Loading branch information
awhiemstra committed Oct 27, 2016
1 parent 6ca45bf commit 9b5e5ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions UM/Application.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def __init__(self, name, version, buildtype = "", **kwargs):

self._plugin_registry.setApplication(self)

UM.Settings.ContainerRegistry.setApplication(self)

self._parsed_command_line = None
self.parseCommandLine()

Expand Down
13 changes: 11 additions & 2 deletions UM/Settings/ContainerRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def _deleteFiles(self, container):
# Load a binary cached version of a DefinitionContainer
def _loadCachedDefinition(self, definition_id, path):
try:
cache_path = Resources.getPath(Resources.Cache, "definitions", definition_id)
cache_path = Resources.getPath(Resources.Cache, "definitions", self.getApplication().getVersion(), definition_id)

cache_mtime = os.path.getmtime(cache_path)
definition_mtime = os.path.getmtime(path)
Expand Down Expand Up @@ -483,7 +483,7 @@ def _loadCachedDefinition(self, definition_id, path):

# Store a cached version of a DefinitionContainer
def _saveCachedDefinition(self, definition):
cache_path = Resources.getStoragePath(Resources.Cache, "definitions", definition.id)
cache_path = Resources.getStoragePath(Resources.Cache, "definitions", self.getApplication().getVersion(), definition.id)

# Ensure the cache path exists
os.makedirs(os.path.dirname(cache_path), exist_ok=True)
Expand All @@ -499,6 +499,15 @@ def getInstance(cls):
ContainerRegistry.__instance = cls()
return ContainerRegistry.__instance

@classmethod
def setApplication(cls, application):
cls.__application = application

@classmethod
def getApplication(cls):
return cls.__application

__application = None
__instance = None

__container_types = {
Expand Down

0 comments on commit 9b5e5ee

Please sign in to comment.