Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added caching to StaticPathFinder

  • Loading branch information...
commit dfc5c55e3b209b75667e96509385176ea1a1563a 1 parent 8c8ce19
@samluescher samluescher authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 media_tree/utils/staticfiles.py
View
7 media_tree/utils/staticfiles.py
@@ -24,6 +24,7 @@ def get_static_storage():
STATIC_STORAGE = get_static_storage()
BUFFERED_ICON_SIZES = {}
+EXISTING_PATHS = {}
class StaticFile(FieldFile):
@@ -75,6 +76,7 @@ def alt(self):
return self.instance.extension
return _('folder')
+
class StaticPathFinder:
@staticmethod
@@ -93,7 +95,10 @@ def find(names, dirs, file_ext):
for dir_name in dirs:
for name in names:
path = os.path.join(dir_name, name + file_ext)
- if STATIC_STORAGE.exists(path):
+ if not path in EXISTING_PATHS:
+ # check on file system, then cache
+ EXISTING_PATHS[path] = STATIC_STORAGE.exists(path)
+ if EXISTING_PATHS[path]:
return path
Please sign in to comment.
Something went wrong with that request. Please try again.