Make sure all temporary directories are removed on errors.

This commit is contained in:
Bastian Kleineidam 2012-05-11 20:19:29 +02:00
parent 8d8da1fecf
commit a690ba28f8
1 changed files with 6 additions and 4 deletions

View File

@ -482,14 +482,16 @@ def _diff_archives (archive1, archive2, **kwargs):
msg = "The diff(1) program is required for showing archive differences, please install it." msg = "The diff(1) program is required for showing archive differences, please install it."
raise util.PatoolError(msg) raise util.PatoolError(msg)
tmpdir1 = util.tmpdir() tmpdir1 = util.tmpdir()
tmpdir2 = util.tmpdir()
try: try:
path1 = _handle_archive(archive1, 'extract', outdir=tmpdir1, **kwargs) path1 = _handle_archive(archive1, 'extract', outdir=tmpdir1, **kwargs)
path2 = _handle_archive(archive2, 'extract', outdir=tmpdir2, **kwargs) tmpdir2 = util.tmpdir()
return util.run([diff, "-urN", path1, path2]) try:
path2 = _handle_archive(archive2, 'extract', outdir=tmpdir2, **kwargs)
return util.run([diff, "-urN", path1, path2])
finally:
shutil.rmtree(tmpdir2, onerror=rmtree_log_error)
finally: finally:
shutil.rmtree(tmpdir1, onerror=rmtree_log_error) shutil.rmtree(tmpdir1, onerror=rmtree_log_error)
shutil.rmtree(tmpdir2, onerror=rmtree_log_error)
def _repack_archive (archive1, archive2, **kwargs): def _repack_archive (archive1, archive2, **kwargs):