From 9b3c44e9fb3d907c0152f14b967e23ab964c0e0b Mon Sep 17 00:00:00 2001 From: Jennifer Lee Date: Thu, 14 Feb 2019 14:54:45 -0800 Subject: [PATCH 6/6] Modify the ID of software image updater object on DBus to allow force update onto same version image In the original design of image update, it does not allow the same version of image to be flashed onto itself. But this blocks validation tests and in most of the cases we don't prevent user from doing such update. This patch appends a random number after the version ID hash string to unblock such limitation. Signed-off-by: Jennifer Lee Change-Id: I16aba4804ae1bc2e8784320f91c0419fb8b23c35 --- image_manager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/image_manager.cpp b/image_manager.cpp index 5b2ff49..e3d26e3 100644 --- a/image_manager.cpp +++ b/image_manager.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -174,6 +175,11 @@ int Manager::processImage(const std::string& tarFilePath) // Compute id auto id = Version::getId(version); + // Append a random number after the original version hash + // This will allow forcing image update onto the same version + srand(time(NULL)); + id = id + "_" + std::to_string(rand()); + fs::path imageDirPath = std::string{IMG_UPLOAD_DIR}; imageDirPath /= id; -- 2.17.1