mirror of https://github.com/wayvr-org/wayvr.git
wayvr: skip unsupported config files (Closes #510)
This commit is contained in:
parent
f30c650bba
commit
ec2e0501c1
|
|
@ -1,7 +1,7 @@
|
||||||
use config::{Config, File};
|
use config::{Config, File};
|
||||||
use log::error;
|
use log::error;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
use wayvr_ipc::packet_client::WvrProcessLaunchParams;
|
use wayvr_ipc::packet_client::WvrProcessLaunchParams;
|
||||||
use wlx_common::{
|
use wlx_common::{
|
||||||
astr_containers::AStrMap,
|
astr_containers::AStrMap,
|
||||||
|
|
@ -45,6 +45,32 @@ where
|
||||||
panic!("No usable config found.");
|
panic!("No usable config found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SUPPORTED_EXTESIONS: [&'static str; 4] = ["yaml", "yml", "json", "json5"];
|
||||||
|
|
||||||
|
fn is_supported_config_file(path: &Path) -> bool {
|
||||||
|
if path.is_dir() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
match path.extension().and_then(|e| e.to_str()) {
|
||||||
|
Some(ext) => {
|
||||||
|
for sup in SUPPORTED_EXTESIONS {
|
||||||
|
if sup.eq_ignore_ascii_case(ext) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log::error!(
|
||||||
|
"Unsupported file extension: \".{}\" in {}. Ignoring file.",
|
||||||
|
ext,
|
||||||
|
path.to_string_lossy()
|
||||||
|
);
|
||||||
|
debug_assert!(false);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn load_config_with_conf_d<ConfigData>(
|
pub fn load_config_with_conf_d<ConfigData>(
|
||||||
root_config_filename: &str,
|
root_config_filename: &str,
|
||||||
ctype: config_io::ConfigRoot,
|
ctype: config_io::ConfigRoot,
|
||||||
|
|
@ -68,7 +94,8 @@ where
|
||||||
if let Ok(paths_unsorted) = std::fs::read_dir(path_conf_d) {
|
if let Ok(paths_unsorted) = std::fs::read_dir(path_conf_d) {
|
||||||
let mut paths: Vec<_> = paths_unsorted
|
let mut paths: Vec<_> = paths_unsorted
|
||||||
.filter_map(|r| match r {
|
.filter_map(|r| match r {
|
||||||
Ok(entry) => Some(entry),
|
Ok(entry) if is_supported_config_file(&entry.path()) => Some(entry),
|
||||||
|
Ok(_other) => None,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to read conf.d directory: {e}");
|
error!("Failed to read conf.d directory: {e}");
|
||||||
None
|
None
|
||||||
|
|
|
||||||
|
|
@ -624,7 +624,6 @@ impl WidgetState {
|
||||||
// firstly, check if this widget is scrollable at all
|
// firstly, check if this widget is scrollable at all
|
||||||
let (active_x, active_y) = get_scroll_active_axis(¶ms.style, ¶ms.taffy_layout);
|
let (active_x, active_y) = get_scroll_active_axis(¶ms.style, ¶ms.taffy_layout);
|
||||||
if active_x || active_y {
|
if active_x || active_y {
|
||||||
log::info!("swipe");
|
|
||||||
self.data.press_down_start_mouse_pos = Some(e.pos);
|
self.data.press_down_start_mouse_pos = Some(e.pos);
|
||||||
self.data.swipe_scroll_start = self.data.scrolling_target;
|
self.data.swipe_scroll_start = self.data.scrolling_target;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue