Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
james58899 committed Oct 24, 2023
1 parent 5a51349 commit 80bb296
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/route/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async fn hath(
.disable_content_disposition()
.set_content_type(info.mime_type())
.into_response(&req);
res.headers_mut().insert(cache_header.0, cache_header.1); // TODO bandwidth limit
res.headers_mut().insert(cache_header.0, cache_header.1);
return res;
}

Expand All @@ -80,8 +80,8 @@ async fn hath(

// Check if the file is already downloading
let download_state = data.download_state.read().get(&info.hash()).cloned();
let (temp_path, mut rx) = if download_state.is_some() {
download_state.unwrap()
let (temp_path, mut rx) = if let Some(state) = download_state {
state
} else {
let temp_path = Arc::new(data.cache_manager.create_temp_file().await);
let (tx, rx) = watch::channel(0); // Download progress
Expand Down
26 changes: 13 additions & 13 deletions src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ impl Settings {
if let Some(disabled) = settings.get("disable_logging").and_then(|s| s.parse().ok()) {
self.disable_logging.store(disabled, Ordering::Relaxed);
}

// TODO update other settings
}
}

Expand Down Expand Up @@ -193,10 +191,12 @@ impl RPCClient {
static_range,
})
} else {
Err(Error::ApiResponseFail {
let err = Error::ApiResponseFail {
fail_code: res.status,
message: res.data.join("\n"),
})
};
error!("Login failed: {}", err);
Err(err)
}
}

Expand Down Expand Up @@ -441,10 +441,10 @@ The program will now terminate.
let min_version = data.get("min_client_build").and_then(|s| s.parse().ok());
let new_version = data.get("cur_client_build").and_then(|s| s.parse().ok());

if min_version.is_none() || new_version.is_none() {
Ok(None)
if let (Some(min), Some(new)) = (min_version, new_version) {
Ok(Some((min, new)))
} else {
Ok(Some((min_version.unwrap(), new_version.unwrap())))
Ok(None)
}
} else {
Err(Error::ApiResponseFail {
Expand Down Expand Up @@ -484,14 +484,14 @@ The program will now terminate.
}

async fn send_request<U: IntoUrl>(&self, url: U) -> Result<String, reqwest::Error> {
let res = self.reqwest
.get(url)
.timeout(Duration::from_secs(600))
.send()
.await?;
let res = self.reqwest.get(url).timeout(Duration::from_secs(600)).send().await?;

if let Err(err) = res.error_for_status_ref() {
warn!("Server response error: code={}, body={}", res.status(), res.text().await.unwrap_or_default());
warn!(
"Server response error: code={}, body={}",
res.status(),
res.text().await.unwrap_or_default()
);
return Err(err);
}

Expand Down

0 comments on commit 80bb296

Please sign in to comment.