From 1908747be2d0cd9fd9545e554d19731e67838f4b Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sun, 10 Apr 2011 12:14:21 +0200 Subject: [PATCH] Force saving of the compressed file when using --force option. --- compressor/base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compressor/base.py b/compressor/base.py index 8f24b0d..deafd4e 100644 --- a/compressor/base.py +++ b/compressor/base.py @@ -169,23 +169,23 @@ class Compressor(object): # Then check for the appropriate output method and call it output_func = getattr(self, "output_%s" % mode, None) if callable(output_func): - return output_func(mode, content) + return output_func(mode, content, forced) # Total failure, raise a general exception raise CompressorError( "Couldn't find output method for mode '%s'" % mode) - def output_file(self, mode, content): + def output_file(self, mode, content, forced=False): """ The output method that saves the content to a file and renders the appropriate template with the file's URL. """ new_filepath = self.filepath(self.content) - if not self.storage.exists(new_filepath): + if not self.storage.exists(new_filepath) or forced: self.storage.save(new_filepath, ContentFile(content)) url = self.storage.url(new_filepath) return self.render_output(mode, {"url": url}) - def output_inline(self, mode, content): + def output_inline(self, mode, content, forced=False): """ The output method that directly returns the content for inline display.