OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """A git command for managing a local cache of git repositories.""" | 6 """A git command for managing a local cache of git repositories.""" |
7 | 7 |
8 from __future__ import print_function | 8 from __future__ import print_function |
9 import errno | 9 import errno |
10 import logging | 10 import logging |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 # Creating a temp file and then deleting it ensures we can use this name. | 354 # Creating a temp file and then deleting it ensures we can use this name. |
355 _, tmp_zipfile = tempfile.mkstemp(suffix='.zip') | 355 _, tmp_zipfile = tempfile.mkstemp(suffix='.zip') |
356 os.remove(tmp_zipfile) | 356 os.remove(tmp_zipfile) |
357 subprocess.call(['zip', '-r', tmp_zipfile, '.'], cwd=self.mirror_path) | 357 subprocess.call(['zip', '-r', tmp_zipfile, '.'], cwd=self.mirror_path) |
358 gsutil = Gsutil(path=self.gsutil_exe, boto_path=None) | 358 gsutil = Gsutil(path=self.gsutil_exe, boto_path=None) |
359 dest_name = 'gs://%s/%s/%s.zip' % ( | 359 dest_name = 'gs://%s/%s/%s.zip' % ( |
360 self.bootstrap_bucket, self.basedir, gen_number) | 360 self.bootstrap_bucket, self.basedir, gen_number) |
361 gsutil.call('cp', tmp_zipfile, dest_name) | 361 gsutil.call('cp', tmp_zipfile, dest_name) |
362 os.remove(tmp_zipfile) | 362 os.remove(tmp_zipfile) |
363 | 363 |
364 @staticmethod | |
365 def DeleteTmpPackFiles(path): | |
366 pack_dir = os.path.join(path, 'objects', 'pack') | |
367 pack_files = [f for f in os.listdir(pack_dir) if | |
368 f.startswith('.tmp-') or f.startswith('tmp_pack_')] | |
iannucci
2014/06/10 23:09:08
since the name of the file is <hex>.{idx,pack}, wh
szager1
2014/06/10 23:38:27
Hmm... Maybe. I'm a bit paranoid.
| |
369 for f in pack_files: | |
370 f = os.path.join(pack_dir, f) | |
371 try: | |
372 os.remove(f) | |
373 logging.warn('Deleted stale temporary pack file %s' % f) | |
374 except OSError: | |
375 logging.warn('Unable to delete temporary pack file %s' % f) | |
364 | 376 |
365 @staticmethod | 377 @staticmethod |
366 def BreakLocks(path): | 378 def BreakLocks(path): |
367 did_unlock = False | 379 did_unlock = False |
368 lf = Lockfile(path) | 380 lf = Lockfile(path) |
369 if lf.break_lock(): | 381 if lf.break_lock(): |
370 did_unlock = True | 382 did_unlock = True |
371 # Look for lock files that might have been left behind by an interrupted | 383 # Look for lock files that might have been left behind by an interrupted |
372 # git process. | 384 # git process. |
373 lf = os.path.join(path, 'config.lock') | 385 lf = os.path.join(path, 'config.lock') |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 return options, args | 539 return options, args |
528 | 540 |
529 | 541 |
530 def main(argv): | 542 def main(argv): |
531 dispatcher = subcommand.CommandDispatcher(__name__) | 543 dispatcher = subcommand.CommandDispatcher(__name__) |
532 return dispatcher.execute(OptionParser(), argv) | 544 return dispatcher.execute(OptionParser(), argv) |
533 | 545 |
534 | 546 |
535 if __name__ == '__main__': | 547 if __name__ == '__main__': |
536 sys.exit(main(sys.argv[1:])) | 548 sys.exit(main(sys.argv[1:])) |
OLD | NEW |