django-pipeline
django-pipeline copied to clipboard
Pipeline does not fail when a file is missing for a bundle
Currently during collectstatic, pipeline doesn't warn or fail at all when a file is missing. Issue #158 raised the same problem but it was closed without a note. I think this shouldn't be the default behavior of django-pipeline as I guess most of the times it's not what the user want.
Totally agree. At least a warning should be generated.
Also, I would like to propose a setting for this. What to do: fail
, warn
, silent
.
@davidt what do you think of it?
I think this is absolutely a great idea.
Ok, I will try to implement it on the weekends.
I'm not sure if this helps but I currently do this with a custom mixin that serves as the basis for my actual storage class:
class MakePipelineExplodePleaseMixin(PipelineMixin):
"""
This class exists solely to cause collectstatic to fail loudly if anything is not findable by the `STATICFILES_FINDERS` *and* they
have been configured within the Django Pipeline configuration settings.
"""
def post_process(self, paths, dry_run=False, **options):
packager = Packager(storage=self)
def _verify_package(p, p_name):
sources = p.config.get("source_filenames")
if len(p.sources) != len(sources):
raise IOError("Could not find all collected files for => %s with %s" % (p_name, sources))
for package_name in packager.packages["css"]:
package = packager.package_for("css", package_name)
_verify_package(package, package_name)
for package_name in packager.packages["js"]:
package = packager.package_for("js", package_name)
_verify_package(package, package_name)
super_class = super(MakePipelineExplodePleaseMixin, self)
if hasattr(super_class, "post_process"):
for name, hashed_name, processed in super_class.post_process(paths.copy(), dry_run, **options):
yield name, hashed_name, processed
Trying to dig into it. Came up with several ideas:
- Updating the
finders
, since it is their jobs to get the file or warn if it does not exist. - Updating the
Compiler
class, basically the_compile
function. - Creating a custom mixin, since it is the easiest approach. Something similar to what @fredpalmer suggested.
What do you think of it? @cyberdelia
Updating the finders, since it is their jobs to get the file or warn if it does not exist.
My interpretation was that the job of the finders is to find the file if it does exist, and allow for other finders in the chain to attempt to find it if it does not.
Any update on this?