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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/legion/data/connection.rb +6 -1
- data/lib/legion/data/version.rb +1 -1
- data/lib/legion/data.rb +27 -17
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 38a6acdfd8b43c7f28928e2c972b292d5f4dac76fe62049600c3cafe617e270c
|
|
4
|
+
data.tar.gz: 00615b710b087d2d71683eca0424b44200cf9d2934d68169196ee9b13252f225
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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:)
|
data/lib/legion/data/version.rb
CHANGED
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
|
-
|
|
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
|