Skip to content

Commit 18633fb

Browse files
jrochkindcbeer
andauthored
Fix Solr 9.7 :dir option handling (#161)
* normalize :dir option to absolute path, for consistent handling in any solr version * Fix attempt to handle dir to conf, go up one dir right way and do not require trailing / * use absolute_path instead of expand_path with . Co-authored-by: Chris Beer <[email protected]> --------- Co-authored-by: Chris Beer <[email protected]>
1 parent 46e7d42 commit 18633fb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/solr_wrapper/instance.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,17 @@ def create(options = {})
159159
create_options[:n] = options[:config_name] if options[:config_name]
160160

161161
if options[:dir]
162+
# Turn a relative path to absolute. Solr 9.7+ changes relative to be
163+
# relative to solr instance dir (which can be a temp dir for us),
164+
# instead of command CWD. Normalize to absolute is good for all.
165+
options[:dir] = File.absolute_path(options[:dir])
166+
162167
# Solr 9.7 required that the dir argument contain a `conf` directory that
163168
# contains the actual configuration files.
164169
if version >= '9.7' && !File.exist?(File.join(options[:dir], 'conf'))
165-
166-
if options[:dir].match?(/conf\/$/)
167-
create_options[:d] = File.expand_path(options[:dir], '..')
170+
# ends in `conf` or `conf/`
171+
if options[:dir].match?(/conf\/?$/)
172+
create_options[:d] = File.expand_path("..", options[:dir])
168173
else
169174
tmpdir = Dir.mktmpdir
170175

0 commit comments

Comments
 (0)