diff mbox series

[2/5] gitsm: Remove downloads/tmpdir when failed

Message ID c4e94db7e266f90dde06cd7d0e73dd3b035e121f.1729933869.git.liezhi.yang@windriver.com
State Accepted, archived
Commit 2ba8d3214759142afc11f0a88d80eb30a8bcde3a
Headers show
Series [1/5] gitsm: Add call_process_submodules() to remove duplicated code | expand

Commit Message

Robert Yang Oct. 26, 2024, 9:39 a.m. UTC
From: Robert Yang <liezhi.yang@windriver.com>

The tmpdir such as downloads/tmplp3cnemv won't be removed without this fix.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 lib/bb/fetch2/gitsm.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Richard Purdie Oct. 28, 2024, 2:06 p.m. UTC | #1
On Sat, 2024-10-26 at 02:39 -0700, Robert Yang via
lists.openembedded.org wrote:
> From: Robert Yang <liezhi.yang@windriver.com>
> 
> The tmpdir such as downloads/tmplp3cnemv won't be removed without
> this fix.
> 
> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>

Thanks, I've been meaning to track down the cause of those!

Steve: We might want to consider this to help the autobuilder.

Cheers,

Richard
Steve Sakoman Oct. 28, 2024, 3:16 p.m. UTC | #2
On Mon, Oct 28, 2024 at 7:06 AM Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> On Sat, 2024-10-26 at 02:39 -0700, Robert Yang via
> lists.openembedded.org wrote:
> > From: Robert Yang <liezhi.yang@windriver.com>
> >
> > The tmpdir such as downloads/tmplp3cnemv won't be removed without
> > this fix.
> >
> > Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
>
> Thanks, I've been meaning to track down the cause of those!
>
> Steve: We might want to consider this to help the autobuilder.

This won't apply unless I also take gitsm: Add
call_process_submodules() to remove duplicated code

I've added both to all three stable branches and will test when the
autobuilder is usable again.

Steve
diff mbox series

Patch

diff --git a/lib/bb/fetch2/gitsm.py b/lib/bb/fetch2/gitsm.py
index 17aac6357..fab4b1164 100644
--- a/lib/bb/fetch2/gitsm.py
+++ b/lib/bb/fetch2/gitsm.py
@@ -152,9 +152,11 @@  class GitSM(Git):
         # unpacked temporarily so that we can examine the .gitmodules file
         if ud.shallow and os.path.exists(ud.fullshallow) and extra_check:
             tmpdir = tempfile.mkdtemp(dir=d.getVar("DL_DIR"))
-            runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=tmpdir)
-            self.process_submodules(ud, tmpdir, subfunc, d)
-            shutil.rmtree(tmpdir)
+            try:
+                runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=tmpdir)
+                self.process_submodules(ud, tmpdir, subfunc, d)
+            finally:
+                shutil.rmtree(tmpdir)
         else:
             self.process_submodules(ud, ud.clonedir, subfunc, d)