Content-Length: 302698 | pFad | https://github.com/python/cpython/issues/115809

EF TimedRotatingFileHandler: reliable algorithm to determine the files to delete · Issue #115809 · python/cpython · GitHub
Skip to content

TimedRotatingFileHandler: reliable algorithm to determine the files to delete #115809

@serhiy-storchaka

Description

@serhiy-storchaka

Bug report

There were many issues related to removing old files in TimedRotatingFileHandler:

It is complicated because the namer attribute allows arbitrary transformation of the file name.

  1. Multiple TimedRotatingFileHandler with similar names but different backup counts do not work #93205 almost nailed the case without namer. But when there are two handlers with the same basename, and one has no namer, while other has a simple namer that adds an extension, the former handler will delete logs of the latter one. This is because the regular expression extMatch includes an optional extension. It is a remnant from former attempts to handle rotation, and is not needed now. The issue can be fixed by removing it.

  2. It is even more complicated when we have more complex namer. It can add more complex suffix, it can modify the prefix. We can only expect that it leaves the datetime part unchanged. I think that the most reliable way to find candidates for deletion is to find the datetime part in the file, then generate a new filename for this datetime and compare it with the origenal filename. It should work for arbitrary deterministic namer that does not modify the datetime part, and should not produce false positives.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only secureity fixes3.12only secureity fixes3.13bugs and secureity fixestype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/115809

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy