Skip to content

Commit 374c321

Browse files
committed
Change Compressor.read_bytes to open local files found via static files finders
1 parent d068a01 commit 374c321

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pipeline/compressors/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from itertools import takewhile
99

10+
from django.contrib.staticfiles import finders
1011
from django.contrib.staticfiles.storage import staticfiles_storage
1112
from django.utils.encoding import smart_bytes, force_text
1213

@@ -211,7 +212,12 @@ def relative_path(self, absolute_path, output_filename):
211212

212213
def read_bytes(self, path):
213214
"""Read file content in binary mode"""
214-
file = staticfiles_storage.open(path)
215+
finder_path = finders.find(path)
216+
if finder_path is not None:
217+
file = open(finder_path)
218+
else:
219+
raise Exception("File '%s' not found via "
220+
"static files finders", path)
215221
content = file.read()
216222
file.close()
217223
return content

0 commit comments

Comments
 (0)