Enable unused_async clippy lint
This commit is contained in:
@@ -38,16 +38,16 @@ impl Console {
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) async fn handle_signal(self: &Arc<Self>, sig: &'static str) {
|
||||
pub(super) fn handle_signal(self: &Arc<Self>, sig: &'static str) {
|
||||
if !self.server.running() {
|
||||
self.interrupt();
|
||||
} else if sig == "SIGINT" {
|
||||
self.interrupt_command();
|
||||
self.start().await;
|
||||
self.start();
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn start(self: &Arc<Self>) {
|
||||
pub fn start(self: &Arc<Self>) {
|
||||
let mut worker_join = self.worker_join.lock().expect("locked");
|
||||
if worker_join.is_none() {
|
||||
let self_ = Arc::clone(self);
|
||||
|
||||
@@ -6,6 +6,7 @@ pub(super) const SIGNAL: &str = "SIGUSR2";
|
||||
|
||||
/// Possibly spawn the terminal console at startup if configured.
|
||||
#[implement(super::Service)]
|
||||
#[allow(clippy::unused_async)]
|
||||
pub(super) async fn console_auto_start(&self) {
|
||||
#[cfg(feature = "console")]
|
||||
if self
|
||||
@@ -16,12 +17,13 @@ pub(super) async fn console_auto_start(&self) {
|
||||
{
|
||||
// Allow more of the startup sequence to execute before spawning
|
||||
tokio::task::yield_now().await;
|
||||
self.console.start().await;
|
||||
self.console.start();
|
||||
}
|
||||
}
|
||||
|
||||
/// Shutdown the console when the admin worker terminates.
|
||||
#[implement(super::Service)]
|
||||
#[allow(clippy::unused_async)]
|
||||
pub(super) async fn console_auto_stop(&self) {
|
||||
#[cfg(feature = "console")]
|
||||
self.console.close().await;
|
||||
|
||||
@@ -194,7 +194,7 @@ impl Service {
|
||||
}
|
||||
|
||||
#[cfg(feature = "console")]
|
||||
self.console.handle_signal(sig).await;
|
||||
self.console.handle_signal(sig);
|
||||
}
|
||||
|
||||
async fn handle_command(&self, command: CommandInput) {
|
||||
|
||||
@@ -106,7 +106,7 @@ impl Service {
|
||||
#[must_use]
|
||||
pub fn is_read_only(&self) -> bool { self.db.db.is_read_only() }
|
||||
|
||||
pub async fn get_registration_tokens(&self) -> HashSet<String> {
|
||||
pub fn get_registration_tokens(&self) -> HashSet<String> {
|
||||
let mut tokens = HashSet::new();
|
||||
if let Some(file) = &self
|
||||
.server
|
||||
|
||||
@@ -57,7 +57,7 @@ impl Manager {
|
||||
|
||||
debug!("Starting service workers...");
|
||||
for service in self.services.services() {
|
||||
self.start_worker(&mut workers, &service).await?;
|
||||
self.start_worker(&mut workers, &service)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -78,7 +78,7 @@ impl Manager {
|
||||
tokio::select! {
|
||||
result = workers.join_next() => match result {
|
||||
Some(Ok(result)) => self.handle_result(&mut workers, result).await?,
|
||||
Some(Err(error)) => self.handle_abort(&mut workers, Error::from(error)).await?,
|
||||
Some(Err(error)) => self.handle_abort(&mut workers, &Error::from(error))?,
|
||||
None => break,
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,8 @@ impl Manager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn handle_abort(&self, _workers: &mut WorkersLocked<'_>, error: Error) -> Result {
|
||||
#[allow(clippy::unused_self)]
|
||||
fn handle_abort(&self, _workers: &mut WorkersLocked<'_>, error: &Error) -> Result {
|
||||
// not supported until service can be associated with abort
|
||||
unimplemented!("unexpected worker task abort {error:?}");
|
||||
}
|
||||
@@ -100,12 +101,13 @@ impl Manager {
|
||||
) -> Result {
|
||||
let (service, result) = result;
|
||||
match result {
|
||||
| Ok(()) => self.handle_finished(workers, &service).await,
|
||||
| Ok(()) => self.handle_finished(workers, &service),
|
||||
| Err(error) => self.handle_error(workers, &service, error).await,
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_finished(
|
||||
#[allow(clippy::unused_self)]
|
||||
fn handle_finished(
|
||||
&self,
|
||||
_workers: &mut WorkersLocked<'_>,
|
||||
service: &Arc<dyn Service>,
|
||||
@@ -136,11 +138,11 @@ impl Manager {
|
||||
warn!("service {name:?} worker restarting after {} delay", time::pretty(delay));
|
||||
sleep(delay).await;
|
||||
|
||||
self.start_worker(workers, service).await
|
||||
self.start_worker(workers, service)
|
||||
}
|
||||
|
||||
/// Start the worker in a task for the service.
|
||||
async fn start_worker(
|
||||
fn start_worker(
|
||||
&self,
|
||||
workers: &mut WorkersLocked<'_>,
|
||||
service: &Arc<dyn Service>,
|
||||
|
||||
@@ -49,13 +49,13 @@ pub struct UrlPreviewData {
|
||||
}
|
||||
|
||||
#[implement(Service)]
|
||||
pub async fn remove_url_preview(&self, url: &str) -> Result {
|
||||
pub fn remove_url_preview(&self, url: &str) -> Result {
|
||||
// TODO: also remove the downloaded image
|
||||
self.db.remove_url_preview(url)
|
||||
}
|
||||
|
||||
#[implement(Service)]
|
||||
pub async fn set_url_preview(&self, url: &str, data: &UrlPreviewData) -> Result {
|
||||
pub fn set_url_preview(&self, url: &str, data: &UrlPreviewData) -> Result {
|
||||
let now = SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.expect("valid system time");
|
||||
@@ -117,7 +117,7 @@ async fn request_url_preview(&self, url: &Url) -> Result<UrlPreviewData> {
|
||||
| _ => return Err!(Request(Unknown("Unsupported Content-Type"))),
|
||||
};
|
||||
|
||||
self.set_url_preview(url.as_str(), &data).await?;
|
||||
self.set_url_preview(url.as_str(), &data)?;
|
||||
|
||||
Ok(data)
|
||||
}
|
||||
@@ -165,6 +165,7 @@ pub async fn download_image(&self, url: &str) -> Result<UrlPreviewData> {
|
||||
|
||||
#[cfg(not(feature = "url_preview"))]
|
||||
#[implement(Service)]
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn download_image(&self, _url: &str) -> Result<UrlPreviewData> {
|
||||
Err!(FeatureDisabled("url_preview"))
|
||||
}
|
||||
@@ -214,6 +215,7 @@ async fn download_html(&self, url: &str) -> Result<UrlPreviewData> {
|
||||
|
||||
#[cfg(not(feature = "url_preview"))]
|
||||
#[implement(Service)]
|
||||
#[allow(clippy::unused_async)]
|
||||
async fn download_html(&self, _url: &str) -> Result<UrlPreviewData> {
|
||||
Err!(FeatureDisabled("url_preview"))
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ async fn hooked_resolve(
|
||||
name: Name,
|
||||
) -> Result<Addrs, Box<dyn std::error::Error + Send + Sync>> {
|
||||
match cache.get_override(name.as_str()).await {
|
||||
| Ok(cached) if cached.valid() => cached_to_reqwest(cached).await,
|
||||
| Ok(cached) if cached.valid() => cached_to_reqwest(cached),
|
||||
| Ok(CachedOverride { overriding, .. }) if overriding.is_some() =>
|
||||
resolve_to_reqwest(
|
||||
server,
|
||||
@@ -241,7 +241,7 @@ async fn resolve_to_reqwest(
|
||||
}
|
||||
}
|
||||
|
||||
async fn cached_to_reqwest(cached: CachedOverride) -> ResolvingResult {
|
||||
fn cached_to_reqwest(cached: CachedOverride) -> ResolvingResult {
|
||||
let addrs = cached
|
||||
.ips
|
||||
.into_iter()
|
||||
|
||||
@@ -172,7 +172,6 @@ impl Service {
|
||||
self.services
|
||||
.state
|
||||
.delete_room_shortstatehash(room_id, &state_lock)
|
||||
.await
|
||||
.log_err()
|
||||
.ok();
|
||||
|
||||
|
||||
@@ -526,7 +526,7 @@ pub async fn get_shortstatehash(&self, shorteventid: ShortEventId) -> Result<Sho
|
||||
}
|
||||
|
||||
#[implement(Service)]
|
||||
pub(super) async fn delete_room_shortstatehash(
|
||||
pub(super) fn delete_room_shortstatehash(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
_mutex_lock: &Guard<OwnedRoomId, ()>,
|
||||
|
||||
@@ -149,11 +149,7 @@ pub async fn try_auth(
|
||||
uiaainfo.completed.push(AuthType::Password);
|
||||
},
|
||||
| AuthData::RegistrationToken(t) => {
|
||||
let tokens = self
|
||||
.services
|
||||
.globals
|
||||
.get_registration_tokens()
|
||||
.await;
|
||||
let tokens = self.services.globals.get_registration_tokens();
|
||||
if tokens.contains(t.token.trim()) {
|
||||
uiaainfo
|
||||
.completed
|
||||
|
||||
@@ -300,13 +300,13 @@ pub fn generate_refresh_token() -> String {
|
||||
}
|
||||
|
||||
#[implement(super::Service)]
|
||||
pub async fn add_to_device_event(
|
||||
pub fn add_to_device_event(
|
||||
&self,
|
||||
sender: &UserId,
|
||||
target_user_id: &UserId,
|
||||
target_device_id: &DeviceId,
|
||||
event_type: &str,
|
||||
content: serde_json::Value,
|
||||
content: &serde_json::Value,
|
||||
) {
|
||||
let count = self.services.globals.next_count();
|
||||
|
||||
|
||||
@@ -381,11 +381,13 @@ impl Service {
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "ldap"))]
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn search_ldap(&self, _user_id: &UserId) -> Result<Vec<(String, bool)>> {
|
||||
Err!(FeatureDisabled("ldap"))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "ldap"))]
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn auth_ldap(&self, _user_dn: &str, _password: &str) -> Result {
|
||||
Err!(FeatureDisabled("ldap"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user