Skip to content

Commit

Permalink
Switch to using os.path for outdated file checks in compilers.
Browse files Browse the repository at this point in the history
The outdated file checks in the compilers were using django storages to check
file existence and compare mtimes, but with my recent change (which restored
the older behavior of comparing the infile and outfile), these were operating
on absolute, local files, which could result in a SuspiciousFileOperation.

The compilers always operate on local files, so we can switch to using the
os.path methods for these instead. This is both more correct and more
efficient.
  • Loading branch information
davidt committed Mar 23, 2016
1 parent 2507820 commit 930b12c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pipeline/compilers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ def output_path(self, path, extension):
return '.'.join((path[0], extension))

def is_outdated(self, infile, outfile):
if not self.storage.exists(outfile):
if not os.path.exists(outfile):
return True

try:
return self.storage.modified_time(infile) > self.storage.modified_time(outfile)
except (OSError, NotImplementedError):
return os.path.getmtime(infile) > os.path.getmtime(outfile)
except OSError:
return True


Expand Down

0 comments on commit 930b12c

Please sign in to comment.