summaryrefslogtreecommitdiff
path: root/include/ruby
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2025-11-25 14:17:03 -0500
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-12-26 11:00:51 +0900
commitbdbe8d50150447748eaa92a0cce7327d8dec9903 (patch)
tree434fe58039a0c54819d314e65adce44d3ac17976 /include/ruby
parentc5376a3a167cbb90023e7610a4fafda22a5c381c (diff)
[ruby/rubygems] Write gem files atomically
This change updates `write_binary` to use a new class, `AtomicFileWriter.open` to write the gem's files. This implementation is borrowed from Active Support's [`atomic_write`](https://github.com/rails/rails/blob/main/activesupport/lib/active_support/core_ext/file/atomic.rb). Atomic write will write the files to a temporary file and then once created, sets permissions and renames the file. If the file is corrupted - ie on failed download, an error occurs, or for some other reason, the real file will not be created. The changes made here make `verify_gz` obsolete, we don't need to verify it if we have successfully created the file atomically. If it exists, it is not corrupt. If it is corrupt, the file won't exist on disk. While writing tests for this functionality I replaced the `RemoteFetcher` stub with `FakeFetcher` except for where we really do need to overwrite the `RemoteFetcher`. The new test implementation is much clearer on what it's trying to accomplish versus the prior test implementation. https://github.com/ruby/rubygems/commit/0cd4b54291
Diffstat (limited to 'include/ruby')
0 files changed, 0 insertions, 0 deletions