for (bf::directory_iterator iter(recovery_dir);
iter != bf::directory_iterator();
++iter) {
- if (bf::is_directory(iter->path()))
+ try {
+ if (bf::is_directory(iter->path()))
+ continue;
+ std::string file = iter->path().filename().string();
+ std::regex recovery_regex(kRecoveryFilePattern);
+ std::smatch match;
+ if (std::regex_search(file, match, recovery_regex)) {
+ LOG(INFO) << "Found recovery file: " << file;
+ std::string type(match[1]);
+ list.emplace_back(type, iter->path().string());
+ }
+ } catch (...) {
+ LOG(WARNING) << "Exception occurred: "
+ << boost::current_exception_diagnostic_information();
continue;
- std::string file = iter->path().filename().string();
- std::regex recovery_regex(kRecoveryFilePattern);
- std::smatch match;
- if (std::regex_search(file, match, recovery_regex)) {
- LOG(INFO) << "Found recovery file: " << file;
- std::string type(match[1]);
- list.emplace_back(type, iter->path().string());
}
}
int main() {
uid_t uid = getuid();
std::vector<std::pair<std::string, std::string>> list;
- try {
- list = SearchRecoveryFiles(uid);
+ list = SearchRecoveryFiles(uid);
+ for (auto entry : list) {
+ if (!RequestRecoveryService(uid, entry.first.c_str(),
+ entry.second.c_str()))
+ LOG(ERROR) << "Failed to recover installation: " << entry.second;
+ }
+
+ if (ci::IsAdminUser(uid)) {
+ list = SearchRecoveryFiles(kGlobalUserUid);
for (auto entry : list) {
if (!RequestRecoveryService(uid, entry.first.c_str(),
entry.second.c_str()))
LOG(ERROR) << "Failed to recover installation: " << entry.second;
}
-
- if (ci::IsAdminUser(uid)) {
- list = SearchRecoveryFiles(kGlobalUserUid);
- for (auto entry : list) {
- if (!RequestRecoveryService(uid, entry.first.c_str(),
- entry.second.c_str()))
- LOG(ERROR) << "Failed to recover installation: " << entry.second;
- }
- }
- } catch (...) {
- std::cerr << "Exception occurred: "
- << boost::current_exception_diagnostic_information() << std::endl;
- return -1;
}
return 0;
}