Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/interscript/ml/provisioning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ def prepare_environment
# we use it to store the Secryst data we need. Otherwise, we try the following
# paths:

possible_paths = [
"/var/lib/secryst",
"/usr/local/share/secryst",
"/usr/share/secryst",
File.join(Dir.home, ".local/share/secryst")
]
possible_paths = candidate_paths

# We find the first writable path to become the primary one. The remaining
# ones will be used read-only if they exist
Expand Down Expand Up @@ -95,6 +90,13 @@ def prepare_environment
@preload_models.each { |i| locate(i) }
end

def self.candidate_paths
[
File.join(Dir.home, ".local/share/interscript-ml"),
File.join(Dir.home, ".local/share/secryst") # legacy fallback
]
end

def locate(name)
# Shortcut this if user gave a filename.
return name if name =~ %r{[.\\/]}
Expand Down
11 changes: 11 additions & 0 deletions spec/stdlib_functions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,14 @@
expect(described_class.name).to eq("Interscript::Stdlib::Functions::SecrystAdapter")
end
end

RSpec.describe Interscript::ML::Provisioning do
describe "candidate paths" do
it "prefers interscript-ml locations, keeping secryst paths as legacy fallbacks" do
paths = described_class.candidate_paths
expect(paths.first).to eq(File.join(Dir.home, ".local/share/interscript-ml"))
expect(paths).to include(File.join(Dir.home, ".local/share/secryst"))
expect(paths.join(" ")).not_to match(%r{/var/lib/secryst})
end
end
end
Loading