diff --git a/whitenoise/compress.py b/whitenoise/compress.py index 69b35219..14658018 100644 --- a/whitenoise/compress.py +++ b/whitenoise/compress.py @@ -69,14 +69,14 @@ def compress(self, path): stat_result = os.fstat(f.fileno()) data = f.read() size = len(data) - if self.use_brotli: + if self.use_brotli and not os.path.isfile(f"{path}.br"): compressed = self.compress_brotli(data) if self.is_compressed_effectively("Brotli", path, size, compressed): yield self.write_data(path, compressed, ".br", stat_result) else: # If Brotli compression wasn't effective gzip won't be either return - if self.use_gzip: + if self.use_gzip and not os.path.isfile(f"{path}.gz"): compressed = self.compress_gzip(data) if self.is_compressed_effectively("Gzip", path, size, compressed): yield self.write_data(path, compressed, ".gz", stat_result)