Skip to content

Commit

Permalink
Use Pathname::cleanpath to fix up broken prefixes (as Ancor suggested)
Browse files Browse the repository at this point in the history
  • Loading branch information
shundhammer committed Aug 24, 2021
1 parent 4840fdb commit 5fe7b63
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/lib/installation/unmounter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# ------------------------------------------------------------------------------

require "yast"
require "pathname"

module Installation
# Class to handle unmounting all mounts from the given subtree on in the
Expand Down Expand Up @@ -74,8 +75,7 @@ def to_s
# read_mounts_file() or add_mount().
#
def initialize(mnt_prefix = "/mnt", mounts_file_name = "/proc/mounts")
@mnt_prefix = mnt_prefix.dup
@mnt_prefix.chomp!("/") unless @mnt_prefix == "/"
@mnt_prefix = Pathname.new(mnt_prefix).cleanpath.to_s
clear
read_mounts_file(mounts_file_name) unless mounts_file_name.nil?
end
Expand Down
6 changes: 3 additions & 3 deletions test/unmounter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def mount(mount_path)
expect(um.mnt_prefix).to eq "/foo"
end

it "does not overdo insanely broken prefixes" do
um = described_class.new("/foo//", nil)
expect(um.mnt_prefix).to eq "/foo/"
it "even fixes up insanely broken prefixes" do
um = described_class.new("/foo///bar///", nil)
expect(um.mnt_prefix).to eq "/foo/bar"
end

it "leaves a root directory prefix as it is" do
Expand Down

0 comments on commit 5fe7b63

Please sign in to comment.