archive mirror
 help / color / mirror / Atom feed
From: Paulo Neves <>
Cc: Paulo Neves <>
Subject: [PATCH 5/5] Replace mkdtemp with TemporaryDirectory and avoid exception masking
Date: Fri, 17 Feb 2023 17:01:16 +0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

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 <>
 lib/bb/fetch2/ | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lib/bb/fetch2/ b/lib/bb/fetch2/
index fcd70fdcf..9445643e5 100644
--- a/lib/bb/fetch2/
+++ b/lib/bb/fetch2/
@@ -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):


  parent reply	other threads:[~2023-02-17 17:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17 17:00 [PATCH 1/5] tests: git-lfs: Restore _find_git_lfs Paulo Neves
2023-02-17 17:00 ` [PATCH 2/5] test: Add real git lfs tests and decorator Paulo Neves
2023-02-17 17:00 ` [PATCH 3/5] git: Remove is None check on _find_git_lfs Paulo Neves
2023-02-22 12:03   ` [bitbake-devel] " Richard Purdie
2023-02-17 17:01 ` [PATCH 4/5] @_contains_lfs: Removed unused variables Paulo Neves
2023-02-17 17:01 ` Paulo Neves [this message]
2023-02-22 12:01 ` [bitbake-devel] [PATCH 1/5] tests: git-lfs: Restore _find_git_lfs Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).