From ec2e0501c105103eb36ec8290825083f5d557e6b Mon Sep 17 00:00:00 2001 From: Aleksander Date: Sun, 3 May 2026 19:35:49 +0200 Subject: [PATCH] wayvr: skip unsupported config files (Closes #510) --- wayvr/src/config.rs | 31 +++++++++++++++++++++++++++++-- wgui/src/widget/mod.rs | 1 - 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/wayvr/src/config.rs b/wayvr/src/config.rs index 9c89a629..237fca9d 100644 --- a/wayvr/src/config.rs +++ b/wayvr/src/config.rs @@ -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( 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 diff --git a/wgui/src/widget/mod.rs b/wgui/src/widget/mod.rs index bcbc1dfb..f82aea71 100644 --- a/wgui/src/widget/mod.rs +++ b/wgui/src/widget/mod.rs @@ -624,7 +624,6 @@ impl WidgetState { // firstly, check if this widget is scrollable at all let (active_x, active_y) = get_scroll_active_axis(¶ms.style, ¶ms.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; }