File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1301,21 +1301,14 @@ void PikaServer::AutoServerlogPurge() {
13011301 std::sort (files.begin (), files.end (),
13021302 [](const auto & a, const auto & b) { return a.second > b.second ; });
13031303
1304- bool has_recent_file = false ;
13051304 for (const auto & [file, log_timestamp] : files) {
13061305 double diff_seconds = difftime (now_timestamp, log_timestamp);
13071306 int64_t interval_days = static_cast <int64_t >(diff_seconds / 86400 );
1308- if (interval_days <= retention_time) {
1309- has_recent_file = true ;
1310- continue ;
1311- }
1312- if (!has_recent_file) {
1313- has_recent_file = true ;
1314- continue ;
1307+ if (interval_days > retention_time) {
1308+ std::string log_file = log_path + " /" + file;
1309+ LOG (INFO) << " Deleting out of date log file: " << log_file;
1310+ if (!pstd::DeleteFile (log_file)) LOG (ERROR) << " Failed to delete log file: " << log_file;
13151311 }
1316- std::string log_file = log_path + " /" + file;
1317- LOG (INFO) << " Deleting out of date log file: " << log_file;
1318- if (!pstd::DeleteFile (log_file)) LOG (ERROR) << " Failed to delete log file: " << log_file;
13191312 }
13201313 }
13211314}
You can’t perform that action at this time.
0 commit comments