Force saving of the compressed file when using --force option.
This commit is contained in:
@@ -169,23 +169,23 @@ class Compressor(object):
|
|||||||
# Then check for the appropriate output method and call it
|
# Then check for the appropriate output method and call it
|
||||||
output_func = getattr(self, "output_%s" % mode, None)
|
output_func = getattr(self, "output_%s" % mode, None)
|
||||||
if callable(output_func):
|
if callable(output_func):
|
||||||
return output_func(mode, content)
|
return output_func(mode, content, forced)
|
||||||
# Total failure, raise a general exception
|
# Total failure, raise a general exception
|
||||||
raise CompressorError(
|
raise CompressorError(
|
||||||
"Couldn't find output method for mode '%s'" % mode)
|
"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 output method that saves the content to a file and renders
|
||||||
the appropriate template with the file's URL.
|
the appropriate template with the file's URL.
|
||||||
"""
|
"""
|
||||||
new_filepath = self.filepath(self.content)
|
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))
|
self.storage.save(new_filepath, ContentFile(content))
|
||||||
url = self.storage.url(new_filepath)
|
url = self.storage.url(new_filepath)
|
||||||
return self.render_output(mode, {"url": url})
|
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
|
The output method that directly returns the content for inline
|
||||||
display.
|
display.
|
||||||
|
|||||||
Reference in New Issue
Block a user