Fix TpkAppQueryInterface when fail to get package id 10/244510/1
authorIlho Kim <ilho159.kim@samsung.com>
Mon, 21 Sep 2020 06:21:06 +0000 (15:21 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Mon, 21 Sep 2020 06:21:06 +0000 (15:21 +0900)
The temporary file should be removed when fail to get package id

Change-Id: I28827f4210bc7af0f7a9c081e87ac1c2dee1ccc9
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/tpk/tpk_app_query_interface.cc

index c25ae1145c2da973ee1721f05ac69f1e3d64ddf8..d4964c8baaedb46ec6b0a2e080f7154f6b3aee5d 100644 (file)
@@ -51,12 +51,16 @@ std::string TpkAppQueryInterface::GetPkgIdFromPath(
   }
 
   tpk::parse::TPKConfigParser parser;
-  if (!parser.ParseManifest(manifest_path))
+  if (!parser.ParseManifest(manifest_path)) {
+    ci::RemoveAll(tmp_path);
     return {};
+  }
   auto package_info = std::static_pointer_cast<const tpk::parse::PackageInfo>(
       parser.GetManifestData(tpk::application_keys::kManifestKey));
-  if (!package_info)
+  if (!package_info) {
+    ci::RemoveAll(tmp_path);
     return {};
+  }
   std::string pkg_id = package_info->package();
   ci::RemoveAll(tmp_path);
   return pkg_id;