From 50d559c9bff3c873ef102f460819cedea64d6963 Mon Sep 17 00:00:00 2001 From: Leonel Gonzalez Date: Fri, 7 Jul 2017 14:38:25 -0500 Subject: image_manager: Added erase method Image manager deletes image, image directory, and the version from its map. Change-Id: Ica128927b706257eb8c4b28d3b9d2ac9ca397b91 Signed-off-by: Leonel Gonzalez --- image_manager.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'image_manager.cpp') diff --git a/image_manager.cpp b/image_manager.cpp index eaf2e6d..bc9ce9e 100644 --- a/image_manager.cpp +++ b/image_manager.cpp @@ -177,6 +177,22 @@ int Manager::processImage(const std::string& tarFilePath) return 0; } +void Manager::erase(std::string entryId) +{ + auto it = versions.find(entryId); + if (it == versions.end()) + { + return; + } + // Delete image dir + fs::path imageDirPath = (*(it->second)).path(); + if (fs::exists(imageDirPath)) + { + fs::remove_all(imageDirPath); + } + this->versions.erase(entryId); +} + int Manager::unTar(const std::string& tarFilePath, const std::string& extractDirPath) { -- cgit v1.2.1