This commit is contained in:
Adrian Heine 2021-08-01 21:21:22 +02:00
parent d6d5d9ebc4
commit 5ca1e45b66
7 changed files with 22 additions and 16 deletions

View file

@ -52,7 +52,7 @@ impl Future for TimerFuture {
}; };
*state = State::Completed; *state = State::Completed;
if let Some(w) = waker { if let Some(w) = waker {
w.wake() w.wake();
} }
}); });
} }

View file

@ -21,19 +21,19 @@ pub trait Logger {
where where
Self: Sized, Self: Sized,
{ {
self.writeln(3, msg) self.writeln(3, msg);
} }
fn debug<S: AsRef<str> + Into<String>>(&self, msg: S) fn debug<S: AsRef<str> + Into<String>>(&self, msg: S)
where where
Self: Sized, Self: Sized,
{ {
self.writeln(4, msg) self.writeln(4, msg);
} }
fn trace<S: AsRef<str> + Into<String>>(&self, msg: S) fn trace<S: AsRef<str> + Into<String>>(&self, msg: S)
where where
Self: Sized, Self: Sized,
{ {
self.writeln(5, msg) self.writeln(5, msg);
} }
fn put<S: AsRef<str> + Into<String>>(&self, entries: impl IntoIterator<Item = Entry<S>>) -> usize fn put<S: AsRef<str> + Into<String>>(&self, entries: impl IntoIterator<Item = Entry<S>>) -> usize
where where
@ -88,12 +88,12 @@ impl<'a, L> FilteringLogger<'a, L> {
impl<'a, L: Logger> Logger for FilteringLogger<'a, L> { impl<'a, L: Logger> Logger for FilteringLogger<'a, L> {
fn write<S: AsRef<str> + Into<String>>(&self, level: Level, str: S) { fn write<S: AsRef<str> + Into<String>>(&self, level: Level, str: S) {
if level <= self.max_level { if level <= self.max_level {
self.logger.write(level, str) self.logger.write(level, str);
} }
} }
fn writeln<S: AsRef<str> + Into<String>>(&self, level: Level, str: S) { fn writeln<S: AsRef<str> + Into<String>>(&self, level: Level, str: S) {
if level <= self.max_level { if level <= self.max_level {
self.logger.writeln(level, str) self.logger.writeln(level, str);
} }
} }
} }

View file

@ -33,7 +33,7 @@ macro_rules! add_generic {
$name::Artifact: Clone $name::Artifact: Clone
),* ),*
{ {
#[allow(unused)] #[allow(unused, clippy::shadow_unrelated)]
async fn add_generic(&self, ($($name,)*): ($($name,)*)) -> Result<(StoringLogger, ($($name::Artifact,)*), bool), (StoringLogger, Box<dyn Error>)> async fn add_generic(&self, ($($name,)*): ($($name,)*)) -> Result<(StoringLogger, ($($name::Artifact,)*), bool), (StoringLogger, Box<dyn Error>)>
{ {
let ($($name,)*) = join!($(self.add($name, false),)*); let ($($name,)*) = join!($(self.add($name, false),)*);

View file

@ -34,6 +34,8 @@ impl<L: 'static, B: 'static, SR: 'static, Rs: Hash + Eq + 'static, As: 'static>
self.0.resources.borrow_mut() self.0.resources.borrow_mut()
} }
// FIXME: https://github.com/rust-lang/rust-clippy/issues/6353
#[allow(clippy::await_holding_refcell_ref)]
pub async fn add<R: AddableResource>(&self, resource: R, force_run: bool) -> InternalAddResult<R> pub async fn add<R: AddableResource>(&self, resource: R, force_run: bool) -> InternalAddResult<R>
where where
Rs: FromResource<R>, Rs: FromResource<R>,

View file

@ -101,6 +101,11 @@ impl<R> SymbolRunner for DelayingSymbolRunner<R>
where where
R: SymbolRunner, R: SymbolRunner,
{ {
#[allow(
clippy::cast_sign_loss,
clippy::cast_possible_truncation,
clippy::cast_precision_loss
)]
async fn run_symbol<S: Symbol + Debug, L: Logger>( async fn run_symbol<S: Symbol + Debug, L: Logger>(
&self, &self,
symbol: &S, symbol: &S,
@ -182,9 +187,9 @@ where
logger.debug(format!("Running symbol {:?}", symbol)); logger.debug(format!("Running symbol {:?}", symbol));
let res = self.0.run_symbol(symbol, logger, force).await; let res = self.0.run_symbol(symbol, logger, force).await;
if let Err(ref e) = res { if let Err(ref e) = res {
logger.info(format!("Failed on {:?} with {}, aborting.", symbol, e)) logger.info(format!("Failed on {:?} with {}, aborting.", symbol, e));
} else { } else {
logger.debug(format!("Successfully finished {:?}", symbol)) logger.debug(format!("Successfully finished {:?}", symbol));
} }
res res
} }

View file

@ -36,13 +36,12 @@ impl<S: AsRef<Path>, U: AsRef<str>, R: CommandRunner> UserService<'_, S, U, R> {
let result = self.command_runner.run_with_args("systemctl", args).await?; let result = self.command_runner.run_with_args("systemctl", args).await?;
if result.status.success() { if result.status.success() {
return Ok(String::from_utf8(result.stdout)?.trim_end().to_string()); return Ok(String::from_utf8(result.stdout)?.trim_end().to_string());
} else { }
let raw_stderr = String::from_utf8(result.stderr)?; let raw_stderr = String::from_utf8(result.stderr)?;
let stderr = raw_stderr.trim_end(); let stderr = raw_stderr.trim_end();
if stderr != "Failed to connect to bus: No such file or directory" { if stderr != "Failed to connect to bus: No such file or directory" {
return Err(stderr.into()); return Err(stderr.into());
} }
}
tries -= 1; tries -= 1;
if tries == 0 { if tries == 0 {
return Err("Gave up waiting for dbus to appear".to_string().into()); return Err("Gave up waiting for dbus to appear".to_string().into());

View file

@ -53,7 +53,7 @@ impl<C: AsRef<str>, D: AsRef<Path>, R: CommandRunner> Translation<'_, C, D, R> {
res.push(( res.push((
format!("https://translate.wordpress.org/projects/wp/{}/{}{}/default/export-translations?format={}", version_x, in_slug, path_locale, format), format!("https://translate.wordpress.org/projects/wp/{}/{}{}/default/export-translations?format={}", version_x, in_slug, path_locale, format),
[self.path.as_ref(), format!("{}{}.{}", out_slug, self.locale.as_ref(), format).as_ref()].iter().collect() [self.path.as_ref(), format!("{}{}.{}", out_slug, self.locale.as_ref(), format).as_ref()].iter().collect()
)) ));
} }
} }
res res