fix and enable collapsible_if lint
Signed-off-by: June Strawberry <june@vern.cc>
This commit is contained in:
@@ -337,10 +337,10 @@ impl Service {
|
||||
let file_rm = fs::remove_file(&path);
|
||||
let legacy_rm = fs::remove_file(&legacy);
|
||||
let (file_rm, legacy_rm) = tokio::join!(file_rm, legacy_rm);
|
||||
if let Err(e) = legacy_rm {
|
||||
if self.services.server.config.media_compat_file_link {
|
||||
debug_error!(?key, ?legacy, "Failed to remove legacy media symlink: {e}");
|
||||
}
|
||||
if let Err(e) = legacy_rm
|
||||
&& self.services.server.config.media_compat_file_link
|
||||
{
|
||||
debug_error!(?key, ?legacy, "Failed to remove legacy media symlink: {e}");
|
||||
}
|
||||
|
||||
Ok(file_rm?)
|
||||
|
||||
@@ -79,10 +79,10 @@ pub async fn get_url_preview(&self, url: &Url) -> Result<UrlPreviewData> {
|
||||
|
||||
#[implement(Service)]
|
||||
async fn request_url_preview(&self, url: &Url) -> Result<UrlPreviewData> {
|
||||
if let Ok(ip) = IPAddress::parse(url.host_str().expect("URL previously validated")) {
|
||||
if !self.services.client.valid_cidr_range(&ip) {
|
||||
return Err!(Request(Forbidden("Requesting from this address is forbidden")));
|
||||
}
|
||||
if let Ok(ip) = IPAddress::parse(url.host_str().expect("URL previously validated"))
|
||||
&& !self.services.client.valid_cidr_range(&ip)
|
||||
{
|
||||
return Err!(Request(Forbidden("Requesting from this address is forbidden")));
|
||||
}
|
||||
|
||||
let client = &self.services.client.url_preview;
|
||||
@@ -93,10 +93,10 @@ async fn request_url_preview(&self, url: &Url) -> Result<UrlPreviewData> {
|
||||
if let Some(remote_addr) = response.remote_addr() {
|
||||
debug!(?url, "URL preview response remote address: {:?}", remote_addr);
|
||||
|
||||
if let Ok(ip) = IPAddress::parse(remote_addr.ip().to_string()) {
|
||||
if !self.services.client.valid_cidr_range(&ip) {
|
||||
return Err!(Request(Forbidden("Requesting from this address is forbidden")));
|
||||
}
|
||||
if let Ok(ip) = IPAddress::parse(remote_addr.ip().to_string())
|
||||
&& !self.services.client.valid_cidr_range(&ip)
|
||||
{
|
||||
return Err!(Request(Forbidden("Requesting from this address is forbidden")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user