Skip to content

Commit ee538eb

Browse files
committed
(PUP-11345) Call FileSystem impl methods directly
Call impl methods directly from within the impl, instead of calling back out to Puppet::FileSystem, as that duplicates assert_path logic and creates more Pathname objects.
1 parent ee43ce6 commit ee538eb

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

lib/puppet/file_system/file_impl.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def chmod(mode, path)
159159

160160
def replace_file(path, mode = nil)
161161
begin
162-
stat = Puppet::FileSystem.lstat(path)
162+
stat = lstat(path)
163163
gid = stat.gid
164164
uid = stat.uid
165165
mode ||= stat.mode & 07777
@@ -180,7 +180,7 @@ def replace_file(path, mode = nil)
180180
tempfile_path = tempfile.path
181181
FileUtils.chown(uid, gid, tempfile_path) if uid && gid
182182
chmod(mode, tempfile_path)
183-
File.rename(tempfile_path, Puppet::FileSystem.path_string(path))
183+
File.rename(tempfile_path, path_string(path))
184184
ensure
185185
tempfile.close!
186186
end

lib/puppet/file_system/jruby.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def unlink(*paths)
1414
def replace_file(path, mode = nil, &block)
1515
# MRI Ruby rename checks if destination is a directory and raises, while
1616
# JRuby removes the directory and replaces the file.
17-
if Puppet::FileSystem.directory?(path)
17+
if directory?(path)
1818
raise Errno::EISDIR, _("Is a directory: %{directory}") % { directory: path }
1919
end
2020

lib/puppet/file_system/windows.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def read_preserve_line_endings(path)
123123
LOCK_VIOLATION = 33
124124

125125
def replace_file(path, mode = nil)
126-
if Puppet::FileSystem.directory?(path)
126+
if directory?(path)
127127
raise Errno::EISDIR, _("Is a directory: %{directory}") % { directory: path }
128128
end
129129

@@ -159,14 +159,14 @@ def replace_file(path, mode = nil)
159159
end
160160

161161
set_dacl(tempfile.path, dacl) if dacl
162-
File.rename(tempfile.path, Puppet::FileSystem.path_string(path))
162+
File.rename(tempfile.path, path_string(path))
163163
ensure
164164
tempfile.close!
165165
end
166166
rescue Puppet::Util::Windows::Error => e
167167
case e.code
168168
when ACCESS_DENIED, SHARING_VIOLATION, LOCK_VIOLATION
169-
raise Errno::EACCES.new(Puppet::FileSystem.path_string(path), e)
169+
raise Errno::EACCES.new(path_string(path), e)
170170
else
171171
raise SystemCallError.new(e.message)
172172
end
@@ -193,7 +193,7 @@ def secure_dacl(current_sid)
193193
end
194194

195195
def get_dacl_from_file(path)
196-
sd = Puppet::Util::Windows::Security.get_security_descriptor(Puppet::FileSystem.path_string(path))
196+
sd = Puppet::Util::Windows::Security.get_security_descriptor(path_string(path))
197197
sd.dacl
198198
rescue Puppet::Util::Windows::Error => e
199199
raise e unless e.code == FILE_NOT_FOUND

0 commit comments

Comments
 (0)