From 60d167f9c0aa21df796772c0b3149f4b45808a05 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 6 Sep 2023 09:23:46 +0100 Subject: [PATCH] Fix issue where compiled file not found in S3 as built locally https://github.com/jazzband/django-pipeline/pull/475 --- pipeline/compressors/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pipeline/compressors/__init__.py b/pipeline/compressors/__init__.py index 200c53d5..6a913224 100644 --- a/pipeline/compressors/__init__.py +++ b/pipeline/compressors/__init__.py @@ -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: @@ -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