FIX: [STUDIO-1419] conflict when removing old logs by multi process

Change-Id: I6529fa649020a2d4419048e470e343bfd63c41bf
This commit is contained in:
chunmao.guo 2022-11-23 08:42:26 +08:00 committed by Lane.Wei
parent 5e02f87980
commit 05904e3770

View file

@ -1159,8 +1159,11 @@ void GUI_App::post_init()
std::vector<std::pair<time_t, std::string>> files_vec; std::vector<std::pair<time_t, std::string>> files_vec;
for (auto& it : boost::filesystem::directory_iterator(log_folder)) { for (auto& it : boost::filesystem::directory_iterator(log_folder)) {
auto temp_path = it.path(); auto temp_path = it.path();
try {
std::time_t lw_t = boost::filesystem::last_write_time(temp_path) ; std::time_t lw_t = boost::filesystem::last_write_time(temp_path) ;
files_vec.push_back({ lw_t, temp_path.filename().string() }); files_vec.push_back({ lw_t, temp_path.filename().string() });
} catch (const std::exception &ex) {
}
} }
std::sort(files_vec.begin(), files_vec.end(), []( std::sort(files_vec.begin(), files_vec.end(), [](
std::pair<time_t, std::string> &a, std::pair<time_t, std::string> &b) { std::pair<time_t, std::string> &a, std::pair<time_t, std::string> &b) {