summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-09 16:44:38 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-09 16:44:38 +0000
commitc3cc16274d2a2cc0b394bb7ec7fbb8b45491abcc (patch)
tree6b32de49708c8f1ba2252ade9f00b20bf92905fd
parentc8ea361d6af3cac2022d3726aafc1d9ae7c52f97 (diff)
downloadpuppet-c3cc16274d2a2cc0b394bb7ec7fbb8b45491abcc.tar.gz
puppet-c3cc16274d2a2cc0b394bb7ec7fbb8b45491abcc.tar.xz
puppet-c3cc16274d2a2cc0b394bb7ec7fbb8b45491abcc.zip
Fixing #309 -- files now correctly replace any number of slashes with a single slash. Also, trailing slashes are removed, since that is how Puppet expects to find files internally.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1749 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/type/pfile.rb4
-rw-r--r--test/types/file.rb15
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index d89fe17e3..3a07acac7 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -421,6 +421,10 @@ module Puppet
@clients = {}
super
+
+ # Get rid of any duplicate slashes, and remove any trailing slashes.
+ @title = @title.gsub(/\/+/, "/").sub(/\/$/, "")
+
# Clean out as many references to any file paths as possible.
# This was the source of many, many bugs.
@arghash = tmphash
diff --git a/test/types/file.rb b/test/types/file.rb
index c4818ba32..fba13bd12 100644
--- a/test/types/file.rb
+++ b/test/types/file.rb
@@ -1451,6 +1451,21 @@ class TestFile < Test::Unit::TestCase
assert(home.requires?(user), "File did not require owner")
assert(home.requires?(group), "File did not require group")
end
+
+ # Testing #309 -- //my/file => /my/file
+ def test_slash_deduplication
+ ["/my/////file/for//testing", "//my/file/for/testing///",
+ "/my/file/for/testing"].each do |path|
+ file = nil
+ assert_nothing_raised do
+ file = Puppet::Type.newfile(:path => path)
+ end
+
+ assert_equal("/my/file/for/testing", file.title)
+ assert_equal(file, Puppet::Type.type(:file)["/my/file/for/testing"])
+ Puppet::Type.type(:file).clear
+ end
+ end
end
# $Id$