Remove atomic_write
workaround.
This commit is contained in:
parent
7129a4852a
commit
bcf8cfc97c
@ -162,18 +162,8 @@ class Pathname
|
|||||||
|
|
||||||
# NOTE: This always overwrites.
|
# NOTE: This always overwrites.
|
||||||
def atomic_write(content)
|
def atomic_write(content)
|
||||||
# The enclosing `mktmpdir` and the `chmod` are a workaround
|
File.atomic_write(self) do |file|
|
||||||
# for https://github.com/rails/rails/pull/34037.
|
file.write(content)
|
||||||
Dir.mktmpdir(".d", dirname) do |tmpdir|
|
|
||||||
should_fix_sticky_bit = dirname.world_writable? && !dirname.sticky?
|
|
||||||
FileUtils.chmod "+t", dirname if should_fix_sticky_bit
|
|
||||||
begin
|
|
||||||
File.atomic_write(self, tmpdir) do |file|
|
|
||||||
file.write(content)
|
|
||||||
end
|
|
||||||
ensure
|
|
||||||
FileUtils.chmod "-t", dirname if should_fix_sticky_bit
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user