Commit edc4d502 by Kyle MacFarlane Committed by Timothée Peignier

fix cleanup for all storages

Signed-off-by: Timothée Peignier <timothee.peignier@tryphon.org>
parent 9c3346f5
...@@ -47,14 +47,18 @@ class Versioning(object): ...@@ -47,14 +47,18 @@ class Versioning(object):
if not (settings.PIPELINE_VERSION and settings.PIPELINE_VERSION_REMOVE_OLD): if not (settings.PIPELINE_VERSION and settings.PIPELINE_VERSION_REMOVE_OLD):
return # Nothing to delete here return # Nothing to delete here
path = os.path.dirname(filename) path = os.path.dirname(filename)
filename = os.path.basename(filename)
filename = settings.PIPELINE_VERSION_PLACEHOLDER.join([re.escape(part) for part in filename.split(settings.PIPELINE_VERSION_PLACEHOLDER)]) filename = settings.PIPELINE_VERSION_PLACEHOLDER.join([re.escape(part) for part in filename.split(settings.PIPELINE_VERSION_PLACEHOLDER)])
regex = re.compile(r'^%s$' % os.path.basename(self.output_filename(filename, r'([A-Za-z0-9]+)'))) regex = re.compile(r'^%s$' % self.output_filename(filename, r'([A-Za-z0-9]+)'))
if storage.exists(path): try:
for f in storage.listdir(path)[1]: for f in storage.listdir(path)[1]:
if regex.match(f): if regex.match(f):
if self.verbose: if self.verbose:
print "Removing outdated file %s" % f print "Removing outdated file %s" % f
storage.delete(os.path.join(path, f)) storage.delete(os.path.join(path, f))
except EnvironmentError:
# We can't use exists() first because some backends (S3) have no concept of directories.
pass
class VersioningBase(object): class VersioningBase(object):
......
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