bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812)

TimedRotatingFileHandler.getFilesToDelete() now sorts only when needed.
This commit is contained in:
Lovesh Harchandani 2017-10-27 09:04:33 +02:00 committed by Vinay Sajip
parent d609b0c24e
commit afad147b59
1 changed files with 1 additions and 1 deletions

View File

@ -353,10 +353,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
suffix = fileName[plen:] suffix = fileName[plen:]
if self.extMatch.match(suffix): if self.extMatch.match(suffix):
result.append(os.path.join(dirName, fileName)) result.append(os.path.join(dirName, fileName))
result.sort()
if len(result) < self.backupCount: if len(result) < self.backupCount:
result = [] result = []
else: else:
result.sort()
result = result[:len(result) - self.backupCount] result = result[:len(result) - self.backupCount]
return result return result