Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
Bug 519229 - Purge cwd after everything else, but only if we still ne…
Browse files Browse the repository at this point in the history
…ed to - r=bhearsum
  • Loading branch information
ccooper committed Jan 12, 2011
1 parent 538a98b commit ab56099
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion buildfarm/maintenance/purge_builds.py
Expand Up @@ -129,8 +129,9 @@ def purge(base_dirs, gigs, ignore, max_age, dry_run=False):
import sys, time
from optparse import OptionParser

cwd = os.path.basename(os.getcwd())
parser = OptionParser(usage=__doc__)
parser.set_defaults(size=5, skip=[], dry_run=False, max_age=14)
parser.set_defaults(size=5, skip=[cwd], dry_run=False, max_age=14)

parser.add_option('-s', '--size',
help='free space required (in GB, default 5)', dest='size',
Expand Down Expand Up @@ -169,6 +170,13 @@ def purge(base_dirs, gigs, ignore, max_age, dry_run=False):

purge(base_dirs, options.size, options.skip, cutoff_time, options.dry_run)
after = freespace(base_dirs[0])/(1024*1024*1024.0)

# Try to cleanup the current dir if we still need space and it will actually help.
if after < options.size:
# We skip the tools dir here because we've usually just cloned it.
purge(['.'], options.size, ['tools'], cutoff_time, options.dry_run)
after = freespace(base_dirs[0])/(1024*1024*1024.0)

if after < options.size:
print "Error: unable to free %1.2f GB of space. " % options.size + \
"Free space only %1.2f GB" % after
Expand Down

0 comments on commit ab56099

Please sign in to comment.