mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Check inotify paths are valid. Add dgu/egpu/ac_online checks
This commit is contained in:
@@ -21,9 +21,19 @@ macro_rules! watch_attr {
|
||||
pub fn fn_name(&self) -> Result<inotify::Inotify> {
|
||||
let mut path = self.$item.clone();
|
||||
path.push($attr_name);
|
||||
let mut inotify = inotify::Inotify::init().unwrap();
|
||||
inotify.add_watch(path.to_str().unwrap(), inotify::WatchMask::MODIFY).unwrap();
|
||||
Ok(inotify)
|
||||
if let Some(path) = path.to_str() {
|
||||
let mut inotify = inotify::Inotify::init()?;
|
||||
inotify.add_watch(path, inotify::WatchMask::MODIFY)
|
||||
.map_err(|e| {
|
||||
if e.kind() == std::io::ErrorKind::NotFound {
|
||||
PlatformError::AttrNotFound(format!("{}", $attr_name))
|
||||
} else {
|
||||
PlatformError::IoPath(format!("{}", path), e)
|
||||
}
|
||||
})?;
|
||||
return Ok(inotify);
|
||||
}
|
||||
Err(PlatformError::AttrNotFound(format!("{}", $attr_name)))
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user