From: Bartlomiej Kunikowski Date: Tue, 14 Feb 2017 08:05:22 +0000 (+0100) Subject: Add some missing error checking X-Git-Tag: submit/tizen/20170308.095023~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c361ecdc5d3ada03fbfb68d20c86f72688c08cb;p=platform%2Fcore%2Fappfw%2Ftpk-backend.git Add some missing error checking Requires: - https://review.tizen.org/gerrit/#/c/114612/ Change-Id: Ia78c272c9f3a2ec8f69993bf6ac2484e28855fb1 --- diff --git a/src/lib/tpk_archive_info.cc b/src/lib/tpk_archive_info.cc index 8aebcbd..a010f58 100644 --- a/src/lib/tpk_archive_info.cc +++ b/src/lib/tpk_archive_info.cc @@ -291,7 +291,7 @@ bool TpkArchiveInfo::GetArchiveInfo(const char* file_path, if (!GetPackageInfo(parser, info)) { LOG(ERROR) << "Failed to get package info"; - bf::remove_all(tmp_dir); + ci::RemoveAll(tmp_dir); return false; } if (!GetAuthorInfo(parser, info)) @@ -310,18 +310,18 @@ bool TpkArchiveInfo::GetArchiveInfo(const char* file_path, bf::path icon_path = bf::path(kSharedResDir) / icon; if (!ExtractPackageArchive( file_path, icon_path.string().c_str(), tmp_dir)) { - bf::remove_all(tmp_dir); + ci::RemoveAll(tmp_dir); return false; } if (!ReadIcon(icon_path, tmp_dir, info)) { LOG(WARNING) << "Failed to get icon info"; - bf::remove_all(tmp_dir); + ci::RemoveAll(tmp_dir); return false; } } free(locale); - bf::remove_all(tmp_dir); + ci::RemoveAll(tmp_dir); return true; } diff --git a/src/tpk/step/filesystem/step_tpk_update_package_directory.cc b/src/tpk/step/filesystem/step_tpk_update_package_directory.cc index 03ca4f8..601828c 100644 --- a/src/tpk/step/filesystem/step_tpk_update_package_directory.cc +++ b/src/tpk/step/filesystem/step_tpk_update_package_directory.cc @@ -76,14 +76,8 @@ ci::Step::Status StepTpkUpdatePackageDirectory::RestoreDirectory( ci::Step::Status StepTpkUpdatePackageDirectory::RemoveDirectory( const boost::filesystem::path& dir_path) { - if (bf::exists(dir_path)) { - bs::error_code error; - bf::remove_all(dir_path, error); - if (error) { - LOG(ERROR) << "Failed to remove directory: " << dir_path; - return Status::APP_DIR_ERROR; - } - } + if (!ci::RemoveAll(dir_path)) + return Status::APP_DIR_ERROR; return Status::OK; } diff --git a/src/tpk/step/pkgmgr/step_convert_xml.cc b/src/tpk/step/pkgmgr/step_convert_xml.cc index 6fedec9..a2f3bea 100644 --- a/src/tpk/step/pkgmgr/step_convert_xml.cc +++ b/src/tpk/step/pkgmgr/step_convert_xml.cc @@ -17,9 +17,11 @@ #include +#include "common/utils/file_util.h" namespace bs = boost::system; namespace bf = boost::filesystem; +namespace ci = common_installer; namespace { @@ -139,12 +141,8 @@ common_installer::Step::Status StepConvertXml::clean() { common_installer::Step::Status StepConvertXml::undo() { if (!backup_path_.empty()) { - bs::error_code error; - bf::remove(new_path_, error); - if (error) { - LOG(WARNING) << "Failed to remove " << new_path_ - << " due to error " << error; - } else { + if (Remove(new_path_) { + bs::error_code error; bf::rename(backup_path_, new_path_, error); if (error) LOG(WARNING) << "Failed to restore " << new_path_ diff --git a/src/tpk/tpk_app_query_interface.cc b/src/tpk/tpk_app_query_interface.cc index f74e7ae..49adc0f 100644 --- a/src/tpk/tpk_app_query_interface.cc +++ b/src/tpk/tpk_app_query_interface.cc @@ -41,12 +41,12 @@ std::string GetPkgIdFromPath(const std::string& path) { return {}; if (!common_installer::ExtractToTmpDir(path.c_str(), tmp_path, kManifestFileName)) { - bf::remove_all(tmp_path, code); + ci::RemoveAll(tmp_path); return {}; } bf::path manifest_path = tmp_path / kManifestFileName; if (!bf::exists(manifest_path)) { - bf::remove_all(tmp_path, code); + ci::RemoveAll(tmp_path); return {}; } @@ -58,7 +58,7 @@ std::string GetPkgIdFromPath(const std::string& path) { if (!package_info) return {}; std::string pkg_id = package_info->package(); - bf::remove_all(tmp_path, code); + ci::RemoveAll(tmp_path); return pkg_id; }