File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1313,21 +1313,14 @@ void PikaServer::AutoServerlogPurge() {
13131313 std::sort (files.begin (), files.end (),
13141314 [](const auto & a, const auto & b) { return a.second > b.second ; });
13151315
1316- bool has_recent_file = false ;
13171316 for (const auto & [file, log_timestamp] : files) {
13181317 double diff_seconds = difftime (now_timestamp, log_timestamp);
13191318 int64_t interval_days = static_cast <int64_t >(diff_seconds / 86400 );
1320- if (interval_days <= retention_time) {
1321- has_recent_file = true ;
1322- continue ;
1323- }
1324- if (!has_recent_file) {
1325- has_recent_file = true ;
1326- continue ;
1319+ if (interval_days > retention_time) {
1320+ std::string log_file = log_path + " /" + file;
1321+ LOG (INFO) << " Deleting out of date log file: " << log_file;
1322+ if (!pstd::DeleteFile (log_file)) LOG (ERROR) << " Failed to delete log file: " << log_file;
13271323 }
1328- std::string log_file = log_path + " /" + file;
1329- LOG (INFO) << " Deleting out of date log file: " << log_file;
1330- if (!pstd::DeleteFile (log_file)) LOG (ERROR) << " Failed to delete log file: " << log_file;
13311324 }
13321325 }
13331326}
You can’t perform that action at this time.
0 commit comments