legion-data 1.8.1 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b3a56b1330f3ec71addc28b9b3b02e6ed845ff80c9993073bde8130fee363ef
4
- data.tar.gz: ccfdf0a86f6408b201065d414ab6199cacf6610e0bfbb527449e59cf970fddb8
3
+ metadata.gz: 38a6acdfd8b43c7f28928e2c972b292d5f4dac76fe62049600c3cafe617e270c
4
+ data.tar.gz: 00615b710b087d2d71683eca0424b44200cf9d2934d68169196ee9b13252f225
5
5
  SHA512:
6
- metadata.gz: b40d2cde196b2c8fec186671ee7973ac85893239e9502445d975ccfaca43efdd8170e04082869f30bd0544cb42a9b090b1190c5ef942c6afa37fa07622874854
7
- data.tar.gz: c9e5c0e72a62c423a532b1be4d34ec98fd6b7b9611232939e5e57f3e61e3f56cc14eb19c5df57855cb3735ee76f6e00338e6a610fa81989e0acfba27c4fceb6a
6
+ metadata.gz: 6dbf52624a9780173930c096f4fcd58216e6bcd59ffaa832d137446753dbb39eb293e17c6e2288dbce1451bc77cf5fa366d55d6ce99901794e82d871ca679ad7
7
+ data.tar.gz: 50ea8e3806bdf7de608af572802c8edf6ba40c77c2c42857ed4d7a7ec85470c29c3345771aefa62bbb92d7fd466fad1f3fce1d8b9ab85d404fd42bed70e70554
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.8.2] - 2026-05-07
6
+
7
+ ### Changed
8
+ - Refactored `Legion::Data.setup` to call `setup_global`, `setup_cache`, then `setup_local` in explicit order — eliminates the `ensure setup_local` footgun that ran local SQLite even when global setup failed.
9
+ - Extracted `setup_global` (connection + migrate + load_models) and promoted `setup_local` and `setup_cache` to top-level public methods with their own `rescue` blocks (`fatal` for local/global, `error` for cache).
10
+ - SQLite main database now resolves to `~/.legionio/data/legionio.db` instead of a relative path in the process working directory; existing absolute path overrides in settings are unchanged.
11
+
5
12
  ## [1.8.1] - 2026-05-07
6
13
 
7
14
  ### Fixed
@@ -365,7 +365,12 @@ module Legion
365
365
  end
366
366
 
367
367
  def sqlite_path
368
- Legion::Settings[:data][:creds][:database] || 'legionio.db'
368
+ path = Legion::Settings[:data][:creds][:database] || 'legionio.db'
369
+ return path if File.absolute_path?(path)
370
+
371
+ base_dir = File.expand_path('~/.legionio/data')
372
+ FileUtils.mkdir_p(base_dir)
373
+ File.join(base_dir, path)
369
374
  end
370
375
 
371
376
  def connection_opts_for(adapter:, opts:)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module Data
5
- VERSION = '1.8.1'
5
+ VERSION = '1.8.2'
6
6
  end
7
7
  end
data/lib/legion/data.rb CHANGED
@@ -44,14 +44,38 @@ module Legion
44
44
 
45
45
  def setup
46
46
  log.info 'Legion::Data setup starting'
47
- connection_setup
48
- migrate
49
- load_models
47
+ setup_global
50
48
  setup_cache
51
49
  setup_local
52
50
  log.info 'Legion::Data setup complete'
53
51
  end
54
52
 
53
+ def setup_local
54
+ return if Legion::Settings[:data].dig(:local, :enabled) == false
55
+
56
+ Legion::Data::Local.setup
57
+ log.info "Legion::Data::Local connected to #{Legion::Data::Local.db_path}"
58
+ rescue StandardError => e
59
+ handle_exception(e, level: :fatal, operation: :setup_local)
60
+ raise
61
+ end
62
+
63
+ def setup_global
64
+ connection_setup
65
+ migrate
66
+ load_models
67
+ rescue StandardError => e
68
+ handle_exception(e, level: :fatal, operation: :setup_global)
69
+ end
70
+
71
+ def setup_cache
72
+ cache_settings = Legion::Settings[:data][:cache]
73
+ setup_static_cache if cache_settings[:static_cache]
74
+ setup_external_cache if cache_settings[:auto_enable] && defined?(::Legion::Cache)
75
+ rescue StandardError => e
76
+ handle_exception(e, level: :error, operation: :setup_cache)
77
+ end
78
+
55
79
  def connection_setup
56
80
  return if Legion::Settings[:data][:connected]
57
81
 
@@ -133,12 +157,6 @@ module Legion
133
157
  @read_privileges = nil
134
158
  end
135
159
 
136
- def setup_cache
137
- cache_settings = Legion::Settings[:data][:cache]
138
- setup_static_cache if cache_settings[:static_cache]
139
- setup_external_cache if cache_settings[:auto_enable] && defined?(::Legion::Cache)
140
- end
141
-
142
160
  def setup_static_cache
143
161
  [Model::Extension, Model::Runner, Model::Function].each do |model|
144
162
  model.plugin :static_cache
@@ -195,14 +213,6 @@ module Legion
195
213
 
196
214
  false
197
215
  end
198
-
199
- def setup_local
200
- return if Legion::Settings[:data].dig(:local, :enabled) == false
201
-
202
- Legion::Data::Local.setup
203
- rescue StandardError => e
204
- handle_exception(e, level: :warn, operation: :setup_local)
205
- end
206
216
  end
207
217
  end
208
218
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity