Skip to content

Large cache_time value to files.download causes OverflowError exception #1394

@link2xt

Description

@link2xt

We used cache_time=9999999999999 to effectively disable redownloading of the file which is supposed to never change. The file downloaded on a first time, but on a second time pyinfra crashed with the exception:

-​-> An internal exception occurred:

  File "/home/*********/relay/venv/lib/python3.11/site-packages/pyinfra/operations/files.py", line 129, in download
    ctime = host.get_fact(Date).replace(tzinfo=None) - timedelta(seconds=cache_time)
    ^^^^^^^^^^^^^^^^^
OverflowError: date value out of range

-​-> The full traceback has been written to pyinfra-debug.log

One way to fix it would be to handle the underflow and assume that the cache has not expired if there is an underflow.

Another option that would have helped us is to not redownload the file if checksum is specified and the file with the correct checksum is already there. This would be preferable for our usecase, then we would not need to specify cache_time at all.

See chatmail/relay#602 for downstream issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions