Skip to content

Commit c4ff03e

Browse files
committed
Fix paths given to compiler.is_outdated.
The check to see whether or not a source file is outdated was being passed the `input_path` and `output_path` variables, which are not the actual paths to files on disk. In particular, `input_path` is the path which will be searched for using the staticfiles finders, and `output_path` is the relative path within the staticfiles root. If the staticfiles root was not the same as the root directory of the project, this would result in the check always reporting that the file was outdated. In addition, if a source file required a finder to locate, the check would fail. Changing this to use `infile` and `outfile` instead means that the check operates on the same file paths that the compiler will. This therefore checks the files that were copied by the collector against the files which are outputted by the compiler, which is a much more correct idea of whether something is out of date. This was tested in conjunction with a custom LessCompiler that uses a helper to introspect dependencies. Before this change, that helper was seeing file paths that did not exist (since STATIC_ROOT is a few subdirectories deep in our codebase). Afterwards, it is able to successfully introspect all the source files to build the dependency tree.
1 parent 0db06ec commit c4ff03e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pipeline/compilers/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ def _compile(input_path):
3131
for compiler in self.compilers:
3232
compiler = compiler(verbose=self.verbose, storage=self.storage)
3333
if compiler.match_file(input_path):
34-
output_path = self.output_path(input_path, compiler.output_extension)
3534
try:
3635
infile = self.storage.path(input_path)
3736
except NotImplementedError:
3837
infile = finders.find(input_path)
3938
outfile = self.output_path(infile, compiler.output_extension)
40-
outdated = compiler.is_outdated(input_path, output_path)
39+
outdated = compiler.is_outdated(infile, outfile)
4140
compiler.compile_file(infile, outfile,
4241
outdated=outdated, force=force)
43-
return output_path
42+
43+
return self.output_path(input_path, compiler.output_extension)
4444
else:
4545
return input_path
4646

0 commit comments

Comments
 (0)