Check the context before processing values

This commit is contained in:
Tobie Morgan Hitchcock 2022-02-25 22:42:14 +00:00
parent 50e026f859
commit 10c0b5c732
2 changed files with 32 additions and 24 deletions

View file

@ -21,6 +21,7 @@ impl Value {
txn: Transaction, txn: Transaction,
chn: UnboundedSender<(Option<Thing>, Value)>, chn: UnboundedSender<(Option<Thing>, Value)>,
) -> Result<(), Error> { ) -> Result<(), Error> {
if ctx.is_ok() {
match self { match self {
Value::Array(v) => v.process(&ctx, &opt, &txn, &chn).await?, Value::Array(v) => v.process(&ctx, &opt, &txn, &chn).await?,
Value::Model(v) => v.process(&ctx, &opt, &txn, &chn).await?, Value::Model(v) => v.process(&ctx, &opt, &txn, &chn).await?,
@ -28,6 +29,7 @@ impl Value {
Value::Table(v) => v.process(&ctx, &opt, &txn, &chn).await?, Value::Table(v) => v.process(&ctx, &opt, &txn, &chn).await?,
v => chn.send((None, v))?, v => chn.send((None, v))?,
} }
}
Ok(()) Ok(())
} }
} }
@ -42,6 +44,7 @@ impl Array {
chn: &UnboundedSender<(Option<Thing>, Value)>, chn: &UnboundedSender<(Option<Thing>, Value)>,
) -> Result<(), Error> { ) -> Result<(), Error> {
for v in self.value.into_iter() { for v in self.value.into_iter() {
if ctx.is_ok() {
match v { match v {
Value::Array(v) => v.process(ctx, opt, txn, chn).await?, Value::Array(v) => v.process(ctx, opt, txn, chn).await?,
Value::Model(v) => v.process(ctx, opt, txn, chn).await?, Value::Model(v) => v.process(ctx, opt, txn, chn).await?,
@ -50,6 +53,7 @@ impl Array {
v => chn.send((None, v))?, v => chn.send((None, v))?,
} }
} }
}
Ok(()) Ok(())
} }
} }

View file

@ -23,6 +23,7 @@ impl Value {
txn: &Transaction, txn: &Transaction,
ite: &mut Iterator<'_>, ite: &mut Iterator<'_>,
) -> Result<(), Error> { ) -> Result<(), Error> {
if ctx.is_ok() {
match self { match self {
Value::Array(v) => v.iterate(ctx, opt, txn, ite).await?, Value::Array(v) => v.iterate(ctx, opt, txn, ite).await?,
Value::Model(v) => v.iterate(ctx, opt, txn, ite).await?, Value::Model(v) => v.iterate(ctx, opt, txn, ite).await?,
@ -30,6 +31,7 @@ impl Value {
Value::Table(v) => v.iterate(ctx, opt, txn, ite).await?, Value::Table(v) => v.iterate(ctx, opt, txn, ite).await?,
v => ite.process(ctx, opt, txn, None, v).await, v => ite.process(ctx, opt, txn, None, v).await,
} }
}
Ok(()) Ok(())
} }
} }
@ -45,6 +47,7 @@ impl Array {
ite: &mut Iterator<'_>, ite: &mut Iterator<'_>,
) -> Result<(), Error> { ) -> Result<(), Error> {
for v in self.value.into_iter() { for v in self.value.into_iter() {
if ctx.is_ok() {
match v { match v {
Value::Array(v) => v.iterate(ctx, opt, txn, ite).await?, Value::Array(v) => v.iterate(ctx, opt, txn, ite).await?,
Value::Model(v) => v.iterate(ctx, opt, txn, ite).await?, Value::Model(v) => v.iterate(ctx, opt, txn, ite).await?,
@ -53,6 +56,7 @@ impl Array {
v => ite.process(ctx, opt, txn, None, v).await, v => ite.process(ctx, opt, txn, None, v).await,
} }
} }
}
Ok(()) Ok(())
} }
} }