From cac414ea31fed449bcbd7055f70ac1fa85f14b93 Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
Date: Thu, 8 Jul 2021 17:43:24 +0000
Subject: [PATCH] ota: log failures to remove temporary state when recovering
 frome errors

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
---
 ota/state.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ota/state.go b/ota/state.go
index f77c81a..504e3bc 100644
--- a/ota/state.go
+++ b/ota/state.go
@@ -144,7 +144,10 @@ func SaveState(state *SystemState, name string) (err error) {
 
 		// Remove the temporary if we have not renamed it yet.
 		if !renamed {
-			_ = os.Remove(f.Name())
+			e2 := os.Remove(f.Name())
+			if e2 != nil {
+				_, _ = fmt.Fprintf(os.Stderr, "%v", e2)
+			}
 		}
 	}()
 
-- 
GitLab