File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 11require 'pathname'
2+ require 'find'
23require 'puppet_forge/error'
34require 'puppet_forge/tar'
45
@@ -55,8 +56,23 @@ def move_into(dir)
5556 def root_dir
5657 return @root_dir if @root_dir
5758
58- # Grab the first directory containing a metadata.json file
59- metadata_file = Dir [ "#{ @tmpdir } /**/metadata.json" ] . sort_by ( &:length ) [ 0 ]
59+ # Use Find.find instead of Dir[] for Windows long path support
60+ metadata_file = nil
61+ shortest_length = Float ::INFINITY
62+
63+ begin
64+ Find . find ( @tmpdir ) do |path |
65+ if File . basename ( path ) == 'metadata.json'
66+ if path . length < shortest_length
67+ metadata_file = path
68+ shortest_length = path . length
69+ end
70+ end
71+ end
72+ rescue Errno ::ENAMETOOLONG => e
73+ # Even Find.find might fail, need to use Dir.each with manual recursion
74+ raise "Cannot traverse directory due to long paths: #{ e . message } "
75+ end
6076
6177 if metadata_file
6278 @root_dir = Pathname . new ( metadata_file ) . dirname
You can’t perform that action at this time.
0 commit comments