summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0013-remove-image-file-on-pre-script-failures.patch
blob: 6bbd59918e488b510b5a8ce2ca82f62973f31066 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From 0628db177655e6f890c4da8c7de7c3cd7487d528 Mon Sep 17 00:00:00 2001
From: Vernon Mauery <vernon.mauery@intel.com>
Date: Thu, 16 Jul 2020 14:16:28 -0700
Subject: [PATCH] remove image file on pre-script failures

Multiple back-to-back updates of bad images will cause the software
manager to leave junk images hanging around. This is part of a fix that
will remove them if the software manager never gets around to launching
the fwupd.sh script. The other part is that the fwupd.sh script must
always delete the image file on exit, success or failure.

Tested: posted a garbage file, saw that it was deleted even though
        fwupd.sh was never invoked.

Change-Id: I6b049916a3edcb48f9d4ebe0d4715b94214b4feb
Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
---
 watch.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/watch.cpp b/watch.cpp
index d6c09a946fd0..5d70edbf52b4 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -106,6 +106,12 @@ int Watch::callback(sd_event_source* /* s */, int fd, uint32_t revents,
             {
                 error("Error ({RC}) processing image {IMAGE}", "RC", rc,
                       "IMAGE", tarballPath);
+                std::error_code ec{};
+                fs::remove_all(tarballPath, ec);
+                if (!ec)
+                {
+                    error("Unable to remove image on processing failure");
+                }
             }
         }
 
-- 
2.17.1