This commit is contained in:
asonix
2020-04-25 20:49:29 -05:00
parent a417a3d054
commit 0b2763ab8b
13 changed files with 27 additions and 28 deletions
+4 -4
View File
@@ -65,15 +65,15 @@ impl ActorCache {
let inbox_host = accepted_actor.inbox().as_url().host();
if input_host != actor_host {
let input_host = input_host.map(|h| h.to_string()).unwrap_or(String::new());
let actor_host = actor_host.map(|h| h.to_string()).unwrap_or(String::new());
let input_host = input_host.map(|h| h.to_string()).unwrap_or_default();
let actor_host = actor_host.map(|h| h.to_string()).unwrap_or_default();
return Err(MyError::HostMismatch(input_host, actor_host));
}
if actor_host != inbox_host {
let actor_host = actor_host.map(|h| h.to_string()).unwrap_or(String::new());
let inbox_host = inbox_host.map(|h| h.to_string()).unwrap_or(String::new());
let actor_host = actor_host.map(|h| h.to_string()).unwrap_or_default();
let inbox_host = inbox_host.map(|h| h.to_string()).unwrap_or_default();
return Err(MyError::HostMismatch(actor_host, inbox_host));
}
+2 -3
View File
@@ -90,9 +90,8 @@ impl Media {
}
pub async fn get_url(&self, uuid: Uuid) -> Result<Option<XsdAnyUri>, MyError> {
match self.url_cache.lock().await.get(&uuid).cloned() {
Some(url) => return Ok(Some(url)),
_ => (),
if let Some(url) = self.url_cache.lock().await.get(&uuid).cloned() {
return Ok(Some(url));
}
let row_opt = self
+4 -4
View File
@@ -179,7 +179,7 @@ impl NodeCache {
let mut write_guard = self.nodes.write().await;
let node = write_guard
.entry(listener.clone())
.or_insert(Node::new(listener));
.or_insert_with(|| Node::new(listener));
if let Some(info) = info {
node.info = Some(info.0);
@@ -212,7 +212,7 @@ impl NodeCache {
let mut write_guard = self.nodes.write().await;
let node = write_guard
.entry(listener.clone())
.or_insert(Node::new(listener.clone()));
.or_insert_with(|| Node::new(listener.clone()));
node.set_info(software, version, reg);
node.clone()
};
@@ -239,7 +239,7 @@ impl NodeCache {
let mut write_guard = self.nodes.write().await;
let node = write_guard
.entry(listener.clone())
.or_insert(Node::new(listener.clone()));
.or_insert_with(|| Node::new(listener.clone()));
node.set_instance(title, description, version, reg, requires_approval);
node.clone()
};
@@ -265,7 +265,7 @@ impl NodeCache {
let mut write_guard = self.nodes.write().await;
let node = write_guard
.entry(listener.clone())
.or_insert(Node::new(listener.clone()));
.or_insert_with(|| Node::new(listener.clone()));
node.set_contact(username, display_name, url, avatar);
node.clone()
};
+2 -3
View File
@@ -206,9 +206,8 @@ impl State {
loop {
interval.tick().await;
match state.rehydrate(&db).await {
Err(e) => error!("Error rehydrating, {}", e),
_ => (),
if let Err(e) = state.rehydrate(&db).await {
error!("Error rehydrating, {}", e);
}
}
});