Closed apelisse closed 7 years ago
This is specifically important when used with httpcache
, as we want to be sure that we don't have partial writes to disk, or even concurrent read/write.
Nice! Can you come up with a test that would succeed with atomic ops and fail without them?
Yeah. We need to come-up with a test that breaks specifically during the Copy
. That should be easy to do if we use a sort of BrokenReader
(I'll see if something already exists to do that) as the input of WriteStream
. Working on this now.
New test is here! I've tested with and without the initial patch, and I'm more confident that it works now :-)
Badass. Thanks!
Implement atomic write by writing into a temporary file (within the same directory to guarantee that it won't move accross disks), with the same permission and then rename at the last moment to make it available.