Skip to content

Commit 3ab3e0a

Browse files
author
Ilja Bobkevic
committed
Recursively traverse for file buffer in directory backend
1 parent 03ac69c commit 3ab3e0a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/puppet_forge_server/backends/directory.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class Directory
2323

2424
# Give highest priority to locally hosted modules
2525
@@PRIORITY = 0
26-
@@FILE_PATH = ''
2726
attr_reader :PRIORITY
2827

2928
def initialize(url)
@@ -41,8 +40,8 @@ def get_metadata(author, name, options = {})
4140
end
4241

4342
def get_file_buffer(relative_path)
44-
path = File.join(File.expand_path(@module_dir), relative_path)
45-
File.open(path, 'r') if File.exist?(path)
43+
path = Dir["#{@module_dir}/**/#{relative_path}"].first
44+
File.open(path, 'r') if path
4645
end
4746

4847
def upload(file_data)
@@ -84,7 +83,7 @@ def get_file_metadata(file_name, options)
8483
file_metadata << {
8584
:metadata => parse_dependencies(PuppetForgeServer::Models::Metadata.new(normalize_metadata(metadata_raw))),
8685
:checksum => options[:with_checksum] == true ? Digest::MD5.file(path).hexdigest : nil,
87-
:path => "/#{Pathname.new(path).relative_path_from(Pathname.new(@module_dir))}".gsub(/^#{@@FILE_PATH}/, '')
86+
:path => "/#{File.basename(path)}"
8887
}
8988
else
9089
@log.error "Failed reading metadata from #{path}"

0 commit comments

Comments
 (0)