From: Junghyun Yeon Date: Fri, 26 Jul 2019 07:25:20 +0000 (+0900) Subject: Fix StepTpkPatchIcons X-Git-Tag: submit/tizen/20190920.015601~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=915ba1e7e1741a44539d74e3851905c6538d9d0b;p=platform%2Fcore%2Fappfw%2Ftpk-backend.git Fix StepTpkPatchIcons - Fix coding rules. - Fix possible static issue. - Add error checking routines. Change-Id: Ic7d8e7a3977a196c872cb55f8ec68116aeeb82ba Signed-off-by: Junghyun Yeon --- diff --git a/src/tpk/step/filesystem/step_tpk_patch_icons.cc b/src/tpk/step/filesystem/step_tpk_patch_icons.cc index 74d8f20..ed15124 100644 --- a/src/tpk/step/filesystem/step_tpk_patch_icons.cc +++ b/src/tpk/step/filesystem/step_tpk_patch_icons.cc @@ -36,10 +36,10 @@ bf::path LocateIcon(const bf::path& filename, const std::string& pkgid, locations.push_back(res_icons_location); for (auto& location : locations) { - if (bf::exists(location)) { + if (bf::exists(location)) return location; - } } + return {}; } @@ -56,16 +56,19 @@ common_installer::Step::Status StepTpkPatchIcons::ProcessIconOutsidePackage( const bf::path& common_icon_location, const bf::path& icon_text, application_x* app, icon_x* icon) { bf::path destination = common_icon_location / app->appid; - if (!icon_text.extension().empty()) { + if (!icon_text.extension().empty()) destination += icon_text.extension(); - } else { + else destination += ".png"; - } - if (!common_installer::CopyFile(icon_text, destination)) { + + if (!common_installer::CopyFile(icon_text, destination)) return Status::ICON_ERROR; - } + free(const_cast(icon->text)); icon->text = strdup(destination.c_str()); + if (!icon->text) + return Status::ICON_ERROR; + return Status::OK; } @@ -78,17 +81,23 @@ common_installer::Step::Status StepTpkPatchIcons::FixIconLocation( context_->is_readonly_package.get()); if (!source.empty()) { LOG(DEBUG) << "Fix location of icon: " << source << " to: " << icon_text; - if (!common_installer::CopyFile(source, icon_text)) { + if (!common_installer::CopyFile(source, icon_text)) return Status::ICON_ERROR; - } } return Status::OK; } common_installer::Step::Status StepTpkPatchIcons::process() { bf::path common_icon_location = context_->GetPkgPath() / "shared" / "res"; + bs::error_code error; bf::create_directories(common_icon_location, error); + if (error) { + LOG(ERROR) << "Failed to create directory :" << common_icon_location + << ", error :" << error.message(); + return Status::ICON_ERROR; + } + for (application_x* app : GListRange(context_->manifest_data.get()->application)) { if (!IsTpkApp(app)) @@ -123,7 +132,7 @@ common_installer::Step::Status StepTpkPatchIcons::process() { } } else { // look for icon in different location if it doesn't exist - if (!bf::exists(icon->text)) { + if (!bf::exists(icon_text)) { Status status = FixIconLocation(icon_text); if (status != Status::OK) return status;