diff options
author | Adriana Kobylak <anoo@us.ibm.com> | 2018-02-12 16:20:13 -0600 |
---|---|---|
committer | Adriana Kobylak <anoo@us.ibm.com> | 2018-02-13 15:39:45 -0600 |
commit | 2b2cd9f74e8e0158f93e3d4bb77346616c889698 (patch) | |
tree | d5d699079a4d12dedb1219f26e39b201475744a6 | |
parent | 4c3edc911ba880f7643f15679018c436aa94e0aa (diff) | |
download | phosphor-bmc-code-mgmt-2b2cd9f74e8e0158f93e3d4bb77346616c889698.tar.gz phosphor-bmc-code-mgmt-2b2cd9f74e8e0158f93e3d4bb77346616c889698.zip |
image_manager: Check if tmp dir exists before remove
There was an error seen where the version manager core dumped when
it tried to remove the temporary directory after a manifest failure:
phosphor-version-software-manager[1264]: Error No manifest file
phosphor-version-software-manager[1264]: terminate called after throwing an
instance of 'std::experimental::filesystem::v1::__cxx11::filesystem_error'
phosphor-version-software-manager[1264]: what(): filesystem error: cannot
remove all: No such file or directory [/tmp/images/imageKcwJFc]
To prevent the core dump, check that the directory exists before trying
to remove it. Create a journal error entry to aid debug since path should
exist.
Change-Id: Ifb47f9a44aa8835c8b7416c7e1a0e67c664d6160
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
-rw-r--r-- | image_manager.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/image_manager.cpp b/image_manager.cpp index 4a27260..69df9dd 100644 --- a/image_manager.cpp +++ b/image_manager.cpp @@ -38,7 +38,16 @@ struct RemovablePath RemovablePath(const fs::path& path) : path(path) {} ~RemovablePath() { - fs::remove_all(path); + if (fs::exists(path)) + { + fs::remove_all(path); + } + else + { + // Path should exist + log<level::ERR>("Error removable path does not exist", + entry("PATH=%s", path.c_str())); + } } }; |