Commit 4795067a by Toby Lawrence

Cautiously grab the content digest.

parent bb29ad5f
...@@ -67,13 +67,13 @@ class StaticContentServer(object): ...@@ -67,13 +67,13 @@ class StaticContentServer(object):
actual_digest = None actual_digest = None
try: try:
content = self.load_asset_from_location(loc) content = self.load_asset_from_location(loc)
actual_digest = content.content_digest actual_digest = getattr(content, "content_digest", None)
except (ItemNotFoundError, NotFoundError): except (ItemNotFoundError, NotFoundError):
return HttpResponseNotFound() return HttpResponseNotFound()
# If this was a versioned asset, and the digest doesn't match, redirect # If this was a versioned asset, and the digest doesn't match, redirect
# them to the actual version. # them to the actual version.
if requested_digest is not None and (actual_digest != requested_digest): if requested_digest is not None and actual_digest is not None and (actual_digest != requested_digest):
actual_asset_path = StaticContent.add_version_to_asset_path(asset_path, actual_digest) actual_asset_path = StaticContent.add_version_to_asset_path(asset_path, actual_digest)
return HttpResponsePermanentRedirect(actual_asset_path) return HttpResponsePermanentRedirect(actual_asset_path)
......
...@@ -243,7 +243,7 @@ class StaticContent(object): ...@@ -243,7 +243,7 @@ class StaticContent(object):
try: try:
content = AssetManager.find(asset_key, as_stream=True) content = AssetManager.find(asset_key, as_stream=True)
serve_from_cdn = not getattr(content, "locked", True) serve_from_cdn = not getattr(content, "locked", True)
content_digest = content.content_digest content_digest = getattr(content, "content_digest", None)
except (ItemNotFoundError, NotFoundError): except (ItemNotFoundError, NotFoundError):
# If we can't find the item, just treat it as if it's locked. # If we can't find the item, just treat it as if it's locked.
serve_from_cdn = False serve_from_cdn = False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment