Commit 16173617 by andreas.pelme

Fixed bug in mtime versioning that caused re-generation of files every

time. Make sure to treat mtimes as ints to avoid comparision errors.
Thanks jbmendelson for the bug report.

git-svn-id: https://django-compress.googlecode.com/svn/trunk@93 98d35234-f74b-0410-9e22-51d878bdf110
parent 549149b3
...@@ -3,23 +3,17 @@ import os ...@@ -3,23 +3,17 @@ import os
from compress.utils import get_output_filename, media_root from compress.utils import get_output_filename, media_root
from compress.versioning.base import VersioningBase from compress.versioning.base import VersioningBase
def max_mtime(files):
return int(max([os.stat(media_root(f)).st_mtime for f in files]))
class MTimeVersioning(VersioningBase): class MTimeVersioning(VersioningBase):
def get_version(self, source_files): def get_version(self, source_files):
mtime = max_mtime(source_files)
try: # Return the modification time for the newest source file
return str(int(mtime)) return str(max([int(os.stat(media_root(f)).st_mtime) for f in source_files]))
except ValueError:
return str(mtime)
def needs_update(self, output_file, source_files, version): def needs_update(self, output_file, source_files, version):
output_file_name = get_output_filename(output_file, version) output_file_name = get_output_filename(output_file, version)
compressed_file_full = media_root(output_file_name) compressed_file_full = media_root(output_file_name)
return (os.stat(compressed_file_full).st_mtime < version), version return (int(os.stat(compressed_file_full).st_mtime) < int(version)), version
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment