Skip to content

Commit

Permalink
Fix issue where compiled file not found in S3 as built locally
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Davis committed Sep 6, 2023
1 parent b9a48bd commit 60d167f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pipeline/compressors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from itertools import takewhile

from django.contrib.staticfiles import finders
from django.contrib.staticfiles.storage import staticfiles_storage
from django.utils.encoding import smart_bytes, force_text
try:
Expand Down Expand Up @@ -216,7 +217,12 @@ def relative_path(self, absolute_path, output_filename):

def read_bytes(self, path):
"""Read file content in binary mode"""
file = staticfiles_storage.open(path)
finder_path = finders.find(path)
if finder_path is not None:
file = open(finder_path)
else:
raise Exception("File '%s' not found via "
"static files finders", path)
content = file.read()
file.close()
return content
Expand Down

0 comments on commit 60d167f

Please sign in to comment.