aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/pathname.rb36
1 files changed, 19 insertions, 17 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index e65dc25ef..c57f38774 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -106,27 +106,29 @@ class Pathname
def atomic_write content
require "tempfile"
tf = Tempfile.new(basename.to_s, dirname)
- tf.binmode
- tf.write(content)
-
begin
- old_stat = stat
- rescue Errno::ENOENT
- old_stat = default_stat
- end
+ tf.binmode
+ tf.write(content)
- uid = Process.uid
- gid = Process.groups.delete(old_stat.gid) { Process.gid }
+ begin
+ old_stat = stat
+ rescue Errno::ENOENT
+ old_stat = default_stat
+ end
- begin
- tf.chown(uid, gid)
- tf.chmod(old_stat.mode)
- rescue Errno::EPERM
- end
+ uid = Process.uid
+ gid = Process.groups.delete(old_stat.gid) { Process.gid }
- File.rename(tf.path, self)
- ensure
- tf.close!
+ begin
+ tf.chown(uid, gid)
+ tf.chmod(old_stat.mode)
+ rescue Errno::EPERM
+ end
+
+ File.rename(tf.path, self)
+ ensure
+ tf.close!
+ end
end
def default_stat