Commit cdfcd7cf authored by szager@chromium.org's avatar szager@chromium.org

Clean up temporary git pack files when breaking locks.

When a git-cache operation is interrupted, it can leave behind large
temporary pack files.  Over time, these pack files will fill up
disks.

R=agable@chromium.org,hinoka@chromium.org,iannucci@chromium.org
BUG=352268

Review URL: https://codereview.chromium.org/326203003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@276208 0039d316-1c4b-4281-b951-d872f2087c98
parent 03fd85bd
......@@ -361,6 +361,18 @@ class Mirror(object):
gsutil.call('cp', tmp_zipfile, dest_name)
os.remove(tmp_zipfile)
@staticmethod
def DeleteTmpPackFiles(path):
pack_dir = os.path.join(path, 'objects', 'pack')
pack_files = [f for f in os.listdir(pack_dir) if
f.startswith('.tmp-') or f.startswith('tmp_pack_')]
for f in pack_files:
f = os.path.join(pack_dir, f)
try:
os.remove(f)
logging.warn('Deleted stale temporary pack file %s' % f)
except OSError:
logging.warn('Unable to delete temporary pack file %s' % f)
@staticmethod
def BreakLocks(path):
......
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