clear unwrap (#8605)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2024-07-04 20:18:53 +08:00
committed by GitHub
parent 94addb162b
commit 86ff768241
11 changed files with 54 additions and 42 deletions

View File

@@ -60,7 +60,7 @@ fn parse_plain_uri_list(v: Vec<u8>) -> Result<String, String> {
#[cfg(all(target_os = "linux", feature = "unix-file-copy-paste"))]
impl ClipboardContext {
pub fn new() -> Result<Self, String> {
pub fn new(_listen: bool) -> Result<Self, String> {
let clipboard = get_clipboard()?;
let string_getter = clipboard
.getter
@@ -95,14 +95,14 @@ impl ClipboardContext {
.load(clip, self.string_getter, prop, TIMEOUT)
.map_err(|e| e.to_string())?;
let file_urls = get_clipboard()?.load(clip, self.text_uri_list, prop, TIMEOUT);
let file_urls = get_clipboard()?.load(clip, self.text_uri_list, prop, TIMEOUT)?;
if file_urls.is_err() || file_urls.as_ref().unwrap().is_empty() {
if file_urls.is_err() || file_urls.as_ref().is_empty() {
log::trace!("clipboard get text, no file urls");
return String::from_utf8(text_content).map_err(|e| e.to_string());
}
let file_urls = parse_plain_uri_list(file_urls.unwrap())?;
let file_urls = parse_plain_uri_list(file_urls)?;
let text_content = String::from_utf8(text_content).map_err(|e| e.to_string())?;

View File

@@ -1069,12 +1069,9 @@ impl FlutterHandler {
// 1. "display 1" will not send the event.
// 2. "displays 0&1" will not send the event. Because it uses texutre render for now.
if !is_sent {
self.display_rgbas
.write()
.unwrap()
.get_mut(&display)
.unwrap()
.valid = false;
if let Some(rgba_data) = self.display_rgbas.write().unwrap().get_mut(&display) {
rgba_data.valid = false;
}
}
}

View File

@@ -24,14 +24,16 @@ macro_rules! configure_http_client {
if let Some(auth) = proxy.intercept.maybe_auth() {
let basic_auth =
format!("Basic {}", auth.get_basic_authorization());
builder = builder.default_headers(
vec![(
reqwest::header::PROXY_AUTHORIZATION,
basic_auth.parse().unwrap(),
)]
.into_iter()
.collect(),
);
if let Ok(auth) = basic_auth.parse() {
builder = builder.default_headers(
vec![(
reqwest::header::PROXY_AUTHORIZATION,
auth,
)]
.into_iter()
.collect(),
);
}
}
builder.build().unwrap_or_else(|e| {
info!("Failed to create a proxied client: {}", e);

View File

@@ -360,7 +360,12 @@ impl Server {
self.services
.keys()
.filter(|k| {
Self::is_video_service_name(k) && self.services.get(*k).unwrap().is_subed(conn_id)
Self::is_video_service_name(k)
&& self
.services
.get(*k)
.map(|s| s.is_subed(conn_id))
.unwrap_or(false)
})
.count()
}