mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 19:08:26 +00:00
Fail fast when multiple addons are run
This commit is contained in:
@ -46,7 +46,12 @@ object AddonExecutor {
|
||||
in.cacheDir,
|
||||
in.addons
|
||||
)
|
||||
rs <- ctx.traverse(c => runAddon(logger.withAddon(c), in.env)(c))
|
||||
rs <-
|
||||
if (cfg.failFast) ctx.foldLeftM(List.empty[AddonResult]) { (res, c) =>
|
||||
if (res.headOption.exists(_.isFailure)) res.pure[F]
|
||||
else runAddon(logger.withAddon(c), in.env)(c).map(r => r :: res)
|
||||
}
|
||||
else ctx.traverse(c => runAddon(logger.withAddon(c), in.env)(c))
|
||||
pure = ctx.foldl(true)((b, c) => b && c.meta.isPure)
|
||||
} yield AddonExecutionResult(rs, pure)
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ case class AddonExecutorConfig(
|
||||
runTimeout: Duration,
|
||||
nspawn: NSpawn,
|
||||
nixRunner: NixConfig,
|
||||
dockerRunner: DockerConfig
|
||||
dockerRunner: DockerConfig,
|
||||
failFast: Boolean
|
||||
)
|
||||
|
||||
object AddonExecutorConfig {
|
||||
|
@ -25,6 +25,7 @@ sealed trait AddonResult {
|
||||
}
|
||||
|
||||
object AddonResult {
|
||||
val emptySuccess: AddonResult = success(AddonOutput.empty)
|
||||
|
||||
/** The addon was run successful, but decoding its stdout failed. */
|
||||
case class DecodingError(message: String) extends AddonResult {
|
||||
|
Reference in New Issue
Block a user