From a690ba28f899d9ef8bf40fc7330580d433ea3693 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Fri, 11 May 2012 20:19:29 +0200 Subject: [PATCH] Make sure all temporary directories are removed on errors. --- patoolib/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/patoolib/__init__.py b/patoolib/__init__.py index 424072b..3b007d2 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -482,14 +482,16 @@ def _diff_archives (archive1, archive2, **kwargs): msg = "The diff(1) program is required for showing archive differences, please install it." raise util.PatoolError(msg) tmpdir1 = util.tmpdir() - tmpdir2 = util.tmpdir() try: path1 = _handle_archive(archive1, 'extract', outdir=tmpdir1, **kwargs) - path2 = _handle_archive(archive2, 'extract', outdir=tmpdir2, **kwargs) - return util.run([diff, "-urN", path1, path2]) + tmpdir2 = util.tmpdir() + 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: shutil.rmtree(tmpdir1, onerror=rmtree_log_error) - shutil.rmtree(tmpdir2, onerror=rmtree_log_error) def _repack_archive (archive1, archive2, **kwargs):