Fix problem requiring two Delete calls to remove an image
- Remove Delete inheritance and method from Version object.
- Add Delete inheritance and method to Activation object.
- Add a listener in the image Manager for deleted Versions and remove
its 'backup' copy of the Version.
Resolves openbmc/openbmc#2086
Change-Id: If41783319cf1ff5b840b747ba457d0570bc52918
Signed-off-by: Eddie James <eajames@us.ibm.com>
diff --git a/image_manager.cpp b/image_manager.cpp
index 5242d8b..357d3c2 100644
--- a/image_manager.cpp
+++ b/image_manager.cpp
@@ -172,10 +172,7 @@
objPath,
version,
purpose,
- imageDirPath.string(),
- std::bind(&Manager::erase,
- this,
- std::placeholders::_1))));
+ imageDirPath.string())));
return 0;
}
@@ -196,6 +193,29 @@
this->versions.erase(entryId);
}
+void Manager::removeVersion(sdbusplus::message::message& msg)
+{
+ namespace mesg = sdbusplus::message;
+
+ mesg::object_path objPath;
+
+ msg.read(objPath);
+ std::string path(std::move(objPath));
+
+ // Version id is the last item in the path
+ auto pos = path.rfind("/");
+ if (pos == std::string::npos)
+ {
+ log<level::INFO>("No version id found in object path",
+ entry("OBJPATH=%s", path));
+ return;
+ }
+
+ auto versionId = path.substr(pos + 1);
+
+ erase(versionId);
+}
+
int Manager::unTar(const std::string& tarFilePath,
const std::string& extractDirPath)
{