From 48774222c6aefbf22e45f9328770e0b36d390ada Mon Sep 17 00:00:00 2001 From: Nick LaMuro Date: Tue, 11 Sep 2018 16:53:48 -0500 Subject: [PATCH] [FIXUP] Favor uri_to_local_path; delete mnt_point For MiqLocalMountSession, favor using uri_to_local_path when it does the same thing as `File.join(mnt_point, relative_to_mount(remote_file))`, which saves a decent amount of uncessary code by having to override `mnt_point`. This should behave the same on NFS and SMB as it did previously, but then avoid the code changes for `mnt_point`, which isn't used terribly consistently compared to the instance variable. Ideally, we would want to use avoid the least amount of changes for MiqGenericMountSession as well as the least amount of overrides in MiqLocalMountSession, and I think this does that... I hope. --- .../util/mount/miq_generic_mount_session.rb | 2 +- .../util/mount/miq_local_mount_session.rb | 28 +++---------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/lib/gems/pending/util/mount/miq_generic_mount_session.rb b/lib/gems/pending/util/mount/miq_generic_mount_session.rb index d7f7a27ee..b5bb8f81b 100644 --- a/lib/gems/pending/util/mount/miq_generic_mount_session.rb +++ b/lib/gems/pending/util/mount/miq_generic_mount_session.rb @@ -294,7 +294,7 @@ def download_single(remote_file, local_file) begin reconnect! - relpath = File.join(mnt_point, relative_to_mount(remote_file)) + relpath = uri_to_local_path(remote_file) unless File.exist?(relpath) logger.warn("#{log_header} Remote file: [#{remote_file}] does not exist!") return diff --git a/lib/gems/pending/util/mount/miq_local_mount_session.rb b/lib/gems/pending/util/mount/miq_local_mount_session.rb index 22ed2586e..0395e7c20 100644 --- a/lib/gems/pending/util/mount/miq_local_mount_session.rb +++ b/lib/gems/pending/util/mount/miq_local_mount_session.rb @@ -18,31 +18,11 @@ def disconnect; end # :nodoc: def mount_share; end # :nodoc: # rubocop:enable Style/SingleLineMethods, Layout/EmptyLineBetweenDefs - def relative_to_mount(dest_uri) # :nodoc: - dest_uri + def relative_to_mount(remote_file) # :nodoc: + remote_file end - def uri_to_local_path(dest_uri) # :nodoc: - File.expand_path(dest_uri) - end - - # :nodoc: - # - # This is an override to allow methods that make use of `@mnt_point` to - # behave as we would expect them to. - # - # Determine the mount point relative to the destination file, and just remove - # the portions of the expanded path that already exist in the - # `remote_file_path` (might be everything if `remote_file_path` is a absolute - # path) - def mnt_point - @mnt_point ||= begin - path_str = if remote_file_path.kind_of?(IO) - remote_file_path.path - else - remote_file_path.to_s - end - File.expand_path(path_str).sub(path_str, "") - end + def uri_to_local_path(remote_file) # :nodoc: + File.expand_path(remote_file) end end