diff --git a/lib/train/extras/aix_file.rb b/lib/train/extras/aix_file.rb index 9addab4d..e755f7f2 100644 --- a/lib/train/extras/aix_file.rb +++ b/lib/train/extras/aix_file.rb @@ -28,9 +28,9 @@ def link_path ) end - def mounted? + def mounted @mounted ||= ( - !@backend.run_command("lsfs -c #{@spath}").stdout.empty? + @backend.run_command("lsfs -c #{@spath}") ) end end diff --git a/lib/train/extras/file_common.rb b/lib/train/extras/file_common.rb index 834c2bd1..247e9caf 100644 --- a/lib/train/extras/file_common.rb +++ b/lib/train/extras/file_common.rb @@ -102,6 +102,10 @@ def unix_mode_mask(owner, type) t & o end + def mounted? + !mounted.nil? && !mounted.stdout.nil? && !mounted.stdout.empty? + end + # helper methods provided to any implementing class private diff --git a/lib/train/extras/linux_file.rb b/lib/train/extras/linux_file.rb index 3a0cda1b..36eb422d 100644 --- a/lib/train/extras/linux_file.rb +++ b/lib/train/extras/linux_file.rb @@ -43,10 +43,9 @@ def link_path ) end - def mounted? + def mounted @mounted ||= ( - !@backend.run_command("mount | grep -- ' on #{@spath}'") - .stdout.empty? + @backend.run_command("mount | grep -- ' on #{@spath}'") ) end diff --git a/lib/train/extras/windows_file.rb b/lib/train/extras/windows_file.rb index 8d5283af..33b1b72b 100644 --- a/lib/train/extras/windows_file.rb +++ b/lib/train/extras/windows_file.rb @@ -39,7 +39,7 @@ def link_path nil end - def mounted? + def mounted nil end diff --git a/lib/train/transports/mock.rb b/lib/train/transports/mock.rb index 9db8816e..bd5195cc 100644 --- a/lib/train/transports/mock.rb +++ b/lib/train/transports/mock.rb @@ -110,16 +110,22 @@ class Train::Transports::Mock::Connection class File < FileCommon %w{ exist? mode owner group link_target link_path content mtime size - selinux_label product_version file_version path - type + selinux_label product_version file_version path type }.each do |m| attr_accessor m.tr('?', '').to_sym end - def initialize(_runtime, path) + def initialize(runtime, path) @path = path @type = :unknown @exist = false + @runtime = runtime + end + + def mounted + @mounted ||= ( + @runtime.run_command("mount | grep -- ' on #{@path}'") + ) end end end