mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
feat-webgarages-121 (#129)
### Description Closes #121 ### Please confirm - [x] I am the legal owner or represent the legal owner of all work submitted (including LLM-generated code, if any) - [x] I consent to my changes being added to this FOSS project - [x] I have confirmed that this does not add new errors or warnings with `utils/clippy.sh` - [ ] This PR used LLMs to generate some or all of the code changes Reviewed-on: https://git.ngram.ca/OpenJam/rc-servers/pulls/129
This commit is contained in:
1 parent
a222745841
commit
d2626bb47f
40 files changed
+4012
-282
No files matched your search
@@ -28,17 +28,28 @@ impl CubeConfig {
|
||||
pub fn load(root: impl AsRef<std::path::Path>) -> std::io::Result<Self> {
|
||||
let file = std::fs::File::open(root.as_ref().join(CUBE_CONFIG_FILENAME))?;
|
||||
let buffered = std::io::BufReader::new(file);
|
||||
let result = serde_json::from_reader(buffered)?;
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
let filename = root.as_ref().join(format!("{}.expanded.json", CUBE_CONFIG_FILENAME.trim_end_matches(".json")));
|
||||
let file = std::fs::File::create(filename)?;
|
||||
let buffered = std::io::BufWriter::new(file);
|
||||
serde_json::to_writer_pretty(buffered, &result)?;
|
||||
let result = serde_json::from_reader::<_, Self>(buffered)?;
|
||||
let result = result.expand_with_context();
|
||||
let expanded_filename = root.as_ref().join(format!("{}.expanded.json", CUBE_CONFIG_FILENAME.trim_end_matches(".json")));
|
||||
match std::fs::File::create(&expanded_filename) {
|
||||
Ok(file) => {
|
||||
let buffered = std::io::BufWriter::new(file);
|
||||
serde_json::to_writer_pretty(buffered, &result)?;
|
||||
},
|
||||
Err(e) => {
|
||||
log::info!("Skipping creating {}: {}", expanded_filename.display(), e);
|
||||
}
|
||||
}
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// Populate more of the config for parts of it which need more context for choosing default values
|
||||
fn expand_with_context(mut self) -> Self {
|
||||
// TODO
|
||||
self.cubes.values_mut().for_each(crate::persist::conversion::expand_conversion_data);
|
||||
self
|
||||
}
|
||||
|
||||
/// Performs configuration checks
|
||||
/// Returns true if validation succeeds, false if failed
|
||||
pub fn self_validate(&self, data_path: impl AsRef<std::path::Path>) -> bool {
|
||||
|
||||
Reference in new issue
Block a user