aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Neves <paulo@myneves.com>2023-02-17 17:01:16 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-02-22 12:03:37 +0000
commit36a231d2a45e7c87172196538d18ded81a234774 (patch)
tree8ad78ad9f088e7e9f958364cbea95758d987f444
parenta64ec64c2faf1ac6ce995cdd4e311d8be6046155 (diff)
downloadbitbake-contrib-36a231d2a45e7c87172196538d18ded81a234774.tar.gz
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. Signed-off-by: Paulo Neves <paulo@myneves.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/fetch2/git.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 7ea897420..5bb839313 100644
--- a/lib/bb/fetch2/git.py
+++ b/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):