Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master-1, master-0, and 0.9.4

Properly close pack files on exceptions.

Cherry-picked from max0d41 @ GitHub.

Signed-off-by: Jelmer Vernooij <jelmer@samba.org>

Changeset 4bf10e80dd92

Parent b9f5641e39ba

committed by Jelmer Vernooij

authored by max

Changes to one file · Browse files at 4bf10e80dd92 Showing diff from parent b9f5641e39ba Diff from another changeset...

 
492
493
494
495
 
 
 
 
 
 
 
 
 
496
497
498
 
617
618
619
620
621
622
623
624
625
 
 
 
 
 
 
 
 
 
626
627
628
 
629
630
631
 
492
493
494
 
495
496
497
498
499
500
501
502
503
504
505
506
 
625
626
627
 
 
 
 
 
 
628
629
630
631
632
633
634
635
636
637
 
 
638
639
640
641
@@ -492,7 +492,15 @@
  raise   pack_files.sort(reverse=True)   suffix_len = len(".pack") - return [Pack(f[:-suffix_len]) for _, f in pack_files] + result = [] + try: + for _, f in pack_files: + result.append(Pack(f[:-suffix_len])) + except: + for p in result: + p.close() + raise + return result     def _pack_cache_stale(self):   try: @@ -617,15 +625,17 @@
  :param path: Path to the pack file.   """   p = PackData(path) - entries = p.sorted_entries() - basename = os.path.join(self.pack_dir, - "pack-%s" % iter_sha1(entry[0] for entry in entries)) - f = GitFile(basename+".idx", "wb") - try: - write_pack_index_v2(f, entries, p.get_stored_checksum()) + try: + entries = p.sorted_entries() + basename = os.path.join(self.pack_dir, + "pack-%s" % iter_sha1(entry[0] for entry in entries)) + f = GitFile(basename+".idx", "wb") + try: + write_pack_index_v2(f, entries, p.get_stored_checksum()) + finally: + f.close()   finally: - f.close() - p.close() + p.close()   os.rename(path, basename + ".pack")   final_pack = Pack(basename)   self._add_known_pack(final_pack)