From 97b258985a59fd4cfe982f694f95018dcab22c61 Mon Sep 17 00:00:00 2001 From: Paulo Neves Date: Fri, 17 Feb 2023 17:01:16 +0000 Subject: bitbake: fetch/git: Replace mkdtemp with TemporaryDirectory and avoid exception masking Due to using mkdtemp instead of TemporaryDirectory we needed to manually cleanup the directory in a try finally block. With tempfile.TemporaryDirectory we can handle the cleanup with a "with" statement and not need to manually clean up oursevels. (Bitbake rev: 36a231d2a45e7c87172196538d18ded81a234774) Signed-off-by: Paulo Neves Signed-off-by: Richard Purdie --- bitbake/lib/bb/fetch2/git.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'bitbake/lib/bb/fetch2/git.py') diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index 7ea8974204..5bb8393133 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py @@ -417,8 +417,7 @@ class Git(FetchMethod): # It would be nice to just do this inline here by running 'git-lfs fetch' # on the bare clonedir, but that operation requires a working copy on some # releases of Git LFS. - tmpdir = tempfile.mkdtemp(dir=d.getVar('DL_DIR')) - try: + with tempfile.TemporaryDirectory(dir=d.getVar('DL_DIR')) as tmpdir: # Do the checkout. This implicitly involves a Git LFS fetch. Git.unpack(self, ud, tmpdir, d) @@ -436,8 +435,6 @@ class Git(FetchMethod): # downloaded. if os.path.exists(os.path.join(tmpdir, "git", ".git", "lfs")): runfetchcmd("tar -cf - lfs | tar -xf - -C %s" % ud.clonedir, d, workdir="%s/git/.git" % tmpdir) - finally: - bb.utils.remove(tmpdir, recurse=True) def build_mirror_data(self, ud, d): -- cgit v1.2.3-54-g00ecf