Skip to content

Commit

Permalink
Merge pull request #258 from fieldOfView/fix_prevent_loading_old_cont…
Browse files Browse the repository at this point in the history
…ainers

Prevent loading containers from "old" folders
  • Loading branch information
awhiemstra authored Jun 12, 2017
2 parents 66d00fe + e85ab8f commit 1d17bfc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion UM/Settings/ContainerRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Uranium is released under the terms of the AGPLv3 or higher.

import os
import re #For finding containers with asterisks in the constraints.
import re #For finding containers with asterisks in the constraints and for detecting backup files.
import urllib #For ensuring container file names are proper file names
import urllib.parse
import pickle #For serializing/deserializing Python classes to binary files
Expand Down Expand Up @@ -141,6 +141,8 @@ def getEmptyInstanceContainer(self) -> InstanceContainer:
# that were already added when the first call to this method happened will not be re-added.
def load(self) -> None:
files = []
old_file_expression = re.compile(r"\{sep}old\{sep}\d+\{sep}".format(sep = os.sep))

for resource_type in self._resource_types:
resources = Resources.getAllResourcesOfType(resource_type)

Expand All @@ -152,6 +154,10 @@ def load(self) -> None:
# Pre-process the list of files to insert relevant data
# Most importantly, we need to ensure the loading order is DefinitionContainer, InstanceContainer, ContainerStack
for path in resources:
if old_file_expression.search(path):
# This is a backup file, ignore it.
continue

try:
mime = MimeTypeDatabase.getMimeTypeForFile(path)
except MimeTypeDatabase.MimeTypeNotFoundError:
Expand Down

0 comments on commit 1d17bfc

Please sign in to comment.