Skip to content

Cache files can be corrupted by interrupted writes #94

@wtaranto

Description

@wtaranto

Problem:
While caching data, the data is written directly to final path. Hard interrupts like SIGKILL leave a corrupted cache. This requires manually tracking down and removing the partially cached file. I ran into this when my download was interrupted halfway through.
Solution:
Thankfully, the solution should be pretty simple with no new dependencies: route all cache writes through a small helper that writes to a temp file in the same directory and then uses os.replace() to move to final names. os.replace is atomic so interruptions won't be an issue.

I can develop the PR myself. Just let me know if this sounds good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions