Move duplicate image upload log inside image_manager
The item_updater is called multiple times to createActivation
object when a new image is uploaded. This ends up producing a
log in the journal suggesting the image was already uploaded
even if the image didn't exist before.
Therefore moving the log inside the image_mananger so that its
called once when the image is uploaded.
Resolves openbmc/openbmc#2261
Change-Id: Ia6590a3a77ccb577c65803de3233b06e7bfb1320
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/image_manager.cpp b/image_manager.cpp
index 206722c..6f49f5d 100644
--- a/image_manager.cpp
+++ b/image_manager.cpp
@@ -160,14 +160,22 @@
// Create Version object
auto objPath = std::string{SOFTWARE_OBJPATH} + '/' + id;
- this->versions.insert(std::make_pair(
- id,
- std::make_unique<Version>(
- this->bus,
- objPath,
- version,
- purpose,
- imageDirPath.string())));
+ if (versions.find(id) == versions.end())
+ {
+ this->versions.insert(std::make_pair(
+ id,
+ std::make_unique<Version>(
+ this->bus,
+ objPath,
+ version,
+ purpose,
+ imageDirPath.string())));
+ }
+ else
+ {
+ log<level::INFO>("Software Object with the same version already exists",
+ entry("VERSION_ID=%s", id));
+ }
return 0;
}