You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be much saner overall to instead write to a temporary copy next to the destination file (such as foo.car.tmp for foo.car), and once Finalize has finished with no error, we do a rename that should basically never fail.
This also means that we can teach OpenReadWrite to always remove foo.car.tmp when it's discarded, to ensure we don't leave unfinished business behind.
The method described above should be doable with just a bit of os and io glue. We could use https://pkg.go.dev/github.com/google/renameio#TempFile, though I think pulling in a library for this use case is perhaps overkill. We want to prevent common errors, and we're not that concerned with atomicity between multiple processes - users should not be writing to the same CAR file concurrently.
Right now, OpenReadWrite writes directly to the destination file. This has multiple problems:
It would be much saner overall to instead write to a temporary copy next to the destination file (such as
foo.car.tmp
forfoo.car
), and onceFinalize
has finished with no error, we do a rename that should basically never fail.This also means that we can teach OpenReadWrite to always remove
foo.car.tmp
when it's discarded, to ensure we don't leave unfinished business behind.The method described above should be doable with just a bit of
os
andio
glue. We could use https://pkg.go.dev/github.com/google/renameio#TempFile, though I think pulling in a library for this use case is perhaps overkill. We want to prevent common errors, and we're not that concerned with atomicity between multiple processes - users should not be writing to the same CAR file concurrently.cc @masih @willscott
The text was updated successfully, but these errors were encountered: