lib/facter/resolvers/macosx/mountpoints.rb in facter-4.4.3 vs lib/facter/resolvers/macosx/mountpoints.rb in facter-4.5.0
- old
+ new
@@ -5,31 +5,36 @@
module Macosx
class Mountpoints < BaseResolver
include Facter::Util::Resolvers::FilesystemHelper
init_resolver
+ @log = Facter::Log.new(self)
+
class << self
private
def post_resolve(fact_name, _options)
@fact_list.fetch(fact_name) { read_mounts }
end
def read_mounts
mounts = {}
+ begin
+ Facter::Util::Resolvers::FilesystemHelper.read_mountpoints.each do |fs|
+ device = fs.name
+ filesystem = fs.mount_type
+ path = fs.mount_point
+ options = read_options(fs.options)
- Facter::Util::Resolvers::FilesystemHelper.read_mountpoints.each do |fs|
- device = fs.name
- filesystem = fs.mount_type
- path = fs.mount_point
- options = read_options(fs.options)
-
- mounts[path] = read_stats(path).tap do |hash|
- hash[:device] = device
- hash[:filesystem] = filesystem
- hash[:options] = options if options.any?
+ mounts[path] = read_stats(path).tap do |hash|
+ hash[:device] = device
+ hash[:filesystem] = filesystem
+ hash[:options] = options if options.any?
+ end
end
+ rescue LoadError => e
+ @log.debug("Could not read mounts: #{e}")
end
@fact_list[:mountpoints] = mounts
end
@@ -37,10 +42,10 @@
begin
stats = Facter::Util::Resolvers::FilesystemHelper.read_mountpoint_stats(path)
size_bytes = stats.bytes_total
available_bytes = stats.bytes_available
used_bytes = size_bytes - available_bytes
- rescue Sys::Filesystem::Error
+ rescue Sys::Filesystem::Error, LoadError
size_bytes = used_bytes = available_bytes = 0
end
{
size_bytes: size_bytes,