Fix uncaught exception.
Change-Id: Ib2526443fcc27fd615fb9325282dbfd3515e9844
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
#include "common/pkgmgr_interface.h"
namespace bf = boost::filesystem;
+namespace bs = boost::system;
namespace ci = common_installer;
namespace {
}
GlobalRecoveryFile::~GlobalRecoveryFile() {
- if (bf::exists(recovery_filepath_))
+ bs::error_code ec;
+ if (bf::exists(recovery_filepath_, ec))
ci::Remove(recovery_filepath_);
- if (bf::exists(backup_path_))
+ if (bf::exists(backup_path_, ec))
ci::Remove(backup_path_);
}
}
bool Remove(const bf::path& path) {
- if (!exists(path) && !bf::is_symlink(bf::symlink_status(path)))
+ bs::error_code error;
+ if (!exists(path, error)) {
+ if (error) {
+ LOG(ERROR) << "Cannot remove: " << path << ", " << error.message();
+ return false;
+ }
+ return true;
+ }
+ if (!bf::is_symlink(bf::symlink_status(path)))
return true;
- bs::error_code error;
bf::remove(path, error);
-
if (error) {
LOG(ERROR) << "Cannot remove: " << path << ", " << error.message();
return false;
void PkgRecoveryService::SearchBackupFiles(uid_t uid) {
const bf::path recovery_dir = ci::GetRootAppPath(false, uid);
- for (bf::directory_iterator iter(recovery_dir);
- iter != bf::directory_iterator();
- ++iter) {
- try {
+ try {
+ for (bf::directory_iterator iter(recovery_dir);
+ iter != bf::directory_iterator();
+ ++iter) {
+
std::string file = iter->path().filename().string();
std::regex backup_regex(kBackupFilePattern);
std::smatch match;
bf::remove(orig_file);
bf::rename(iter->path(), orig_file);
}
- } catch (...) {
- LOG(WARNING) << "Exception occurred: "
- << boost::current_exception_diagnostic_information();
- continue;
}
+ } catch (...) {
+ LOG(WARNING) << "Exception occurred: "
+ << boost::current_exception_diagnostic_information();
}
}