Commit 4c3313b3 by Sam Thomson

sort to get the most recent compressed file

rely on the fact that compressed filenames always increase. os.listdir returns filenames in arbitrary order, so they must be sorted (in reverse order) to get the most recent
parent 6f400b9f
......@@ -108,7 +108,7 @@ def get_version_from_file(path, filename):
def remove_files(path, filename, verbosity=0):
regex = re.compile(r'^%s$' % (os.path.basename(get_output_filename(settings.COMPRESS_VERSION_PLACEHOLDER.join([re.escape(part) for part in filename.split(settings.COMPRESS_VERSION_PLACEHOLDER)]), r'[A-Za-z0-9]+'))))
if os.path.exists(path):
for f in os.listdir(path):
for f in sorted(os.listdir(path), reverse=True):
if regex.match(f):
if verbosity >= 1:
print "Removing outdated file %s" % f
......
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