wayvr: skip unsupported config files (Closes #510)

This commit is contained in:
Aleksander 2026-05-03 19:35:49 +02:00
parent f30c650bba
commit ec2e0501c1
2 changed files with 29 additions and 3 deletions

View File

@ -1,7 +1,7 @@
use config::{Config, File};
use log::error;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use wayvr_ipc::packet_client::WvrProcessLaunchParams;
use wlx_common::{
astr_containers::AStrMap,
@ -45,6 +45,32 @@ where
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>(
root_config_filename: &str,
ctype: config_io::ConfigRoot,
@ -68,7 +94,8 @@ where
if let Ok(paths_unsorted) = std::fs::read_dir(path_conf_d) {
let mut paths: Vec<_> = paths_unsorted
.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) => {
error!("Failed to read conf.d directory: {e}");
None

View File

@ -624,7 +624,6 @@ impl WidgetState {
// firstly, check if this widget is scrollable at all
let (active_x, active_y) = get_scroll_active_axis(&params.style, &params.taffy_layout);
if active_x || active_y {
log::info!("swipe");
self.data.press_down_start_mouse_pos = Some(e.pos);
self.data.swipe_scroll_start = self.data.scrolling_target;
}