Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
(FACT-2555) Move conversion to UTF-8 in helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan Irimie committed Apr 28, 2020
1 parent 8cdf10d commit a218ac7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/resolvers/macosx/mountpoints_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def post_resolve(fact_name)
def read_mounts # rubocop:disable Metrics/AbcSize
mounts = {}
FilesystemHelper.read_mountpoints.each do |fs|
device = fs.name.force_encoding('UTF-8')
filesystem = fs.mount_type.force_encoding('UTF-8')
path = fs.mount_point.force_encoding('UTF-8')
options = fs.options.force_encoding('UTF-8').split(',').map(&:strip).map { |o| o == 'rootfs' ? 'root' : o }
device = fs.name
filesystem = fs.mount_type
path = fs.mount_point
options = fs.options.split(',').map(&:strip).map { |o| o == 'rootfs' ? 'root' : o }

next if path =~ %r{^/(proc|sys)} && filesystem != 'tmpfs' || filesystem == 'autofs'

Expand Down
11 changes: 10 additions & 1 deletion lib/resolvers/utils/filesystem_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module FilesystemHelper

def self.read_mountpoints
require 'sys/filesystem'
Sys::Filesystem.mounts
force_utf(Sys::Filesystem.mounts)
end

def self.read_mountpoint_stats(path)
Expand All @@ -25,5 +25,14 @@ def self.compute_capacity(used, total)
'0%'
end
end

def self.force_utf(mounts)
mounts.each do |mount|
mount.name.force_encoding('UTF-8')
mount.mount_type.force_encoding('UTF-8')
mount.mount_point.force_encoding('UTF-8')
mount.options.force_encoding('UTF-8')
end
end
end
end

0 comments on commit a218ac7

Please sign in to comment.