quite if config file not found, remove HW_CODEC_CONFIG, option env LIBGL_ALWAYS_SOFTWARE=1

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-07-30 11:09:14 +08:00
parent 3c4852a254
commit 2c619cbe41
3 changed files with 8 additions and 18 deletions

View File

@@ -52,7 +52,6 @@ lazy_static::lazy_static! {
pub static ref EXE_RENDEZVOUS_SERVER: Arc<RwLock<String>> = Default::default();
pub static ref APP_NAME: Arc<RwLock<String>> = Arc::new(RwLock::new("RustDesk".to_owned()));
static ref KEY_PAIR: Arc<Mutex<Option<KeyPair>>> = Default::default();
static ref HW_CODEC_CONFIG: Arc<RwLock<HwCodecConfig>> = Arc::new(RwLock::new(HwCodecConfig::load()));
static ref USER_DEFAULT_CONFIG: Arc<RwLock<(UserDefaultConfig, Instant)>> = Arc::new(RwLock::new((UserDefaultConfig::load(), Instant::now())));
}
@@ -400,6 +399,11 @@ pub fn load_path<T: serde::Serialize + serde::de::DeserializeOwned + Default + s
let cfg = match confy::load_path(&file) {
Ok(config) => config,
Err(err) => {
if let confy::ConfyError::GeneralLoadError(err) = &err {
if err.kind() == std::io::ErrorKind::NotFound {
return T::default();
}
}
log::error!("Failed to load config '{}': {}", file.display(), err);
T::default()
}
@@ -1358,16 +1362,6 @@ impl HwCodecConfig {
pub fn clear() {
HwCodecConfig::default().store();
}
/// refresh current global HW_CODEC_CONFIG, usually uesd after HwCodecConfig::remove()
pub fn refresh() {
*HW_CODEC_CONFIG.write().unwrap() = HwCodecConfig::load();
log::debug!("HW_CODEC_CONFIG refreshed successfully");
}
pub fn get() -> HwCodecConfig {
return HW_CODEC_CONFIG.read().unwrap().clone();
}
}
#[derive(Debug, Default, Serialize, Deserialize, Clone)]