#include <boost/filesystem/path.hpp>
#include <glib.h>
-#include <common/request.h>
#include <common/utils/file_util.h>
+#include <common/utils/request.h>
#include <common/utils/subprocess.h>
#include <common/utils/user_util.h>
#include <manifest_parser/utils/logging.h>
#include <sys/types.h>
#include <tzplatform_config.h>
+#include <array>
#include <regex>
#include <string>
#include <vector>
// recover normal user packages
ci::UserList list = ci::GetUserList();
- for (auto userinfo : list) {
+ for (const auto& userinfo : list) {
uid_t uid = std::get<0>(userinfo);
LOG(INFO) << "Searching recovery files for user " << std::get<0>(userinfo);
SearchBackupFiles(uid);
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();
}
}
void PkgRecoveryService::ProcessRecovery(uid_t uid,
const std::vector<RecoverEntry>& entries) {
LOG(INFO) << "Process recovery for user " << uid;
- for (auto entry : entries) {
+ for (const auto& entry : entries) {
const char* type = entry.first.c_str();
const char* file = entry.second.c_str();
if (!bf::exists(file))
} // namespace
int main() {
- PkgRecoveryService service;
- service.Run();
- return 0;
+ try {
+ PkgRecoveryService service;
+ service.Run();
+ return 0;
+ } catch(...) {
+ LOG(ERROR) << "Exception occured";
+ return -1;
+ }
}