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.
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.replaceis atomic so interruptions won't be an issue.I can develop the PR myself. Just let me know if this sounds good.