mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-05 10:59:33 +00:00
Merge pull request #1503 from eikek/logging-fix
Avoid logging non-errors as error
This commit is contained in:
commit
a890366d8b
@ -103,10 +103,11 @@ object PeriodicTaskStore {
|
|||||||
|
|
||||||
def insert(task: RPeriodicTask): F[Unit] = {
|
def insert(task: RPeriodicTask): F[Unit] = {
|
||||||
val update = store.transact(RPeriodicTask.update(task))
|
val update = store.transact(RPeriodicTask.update(task))
|
||||||
val insertAttempt = store.transact(RPeriodicTask.insert(task)).attempt.map {
|
val insertAttempt =
|
||||||
case Right(n) => n > 0
|
store.transact(RPeriodicTask.insert(task, silent = true)).attempt.map {
|
||||||
case Left(_) => false
|
case Right(n) => n > 0
|
||||||
}
|
case Left(_) => false
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
n1 <- update
|
n1 <- update
|
||||||
@ -116,7 +117,7 @@ object PeriodicTaskStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def add(task: RPeriodicTask): F[AddResult] = {
|
def add(task: RPeriodicTask): F[AddResult] = {
|
||||||
val insert = RPeriodicTask.insert(task)
|
val insert = RPeriodicTask.insert(task, silent = true)
|
||||||
val exists = RPeriodicTask.exists(task.id)
|
val exists = RPeriodicTask.exists(task.id)
|
||||||
store.add(insert, exists)
|
store.add(insert, exists)
|
||||||
}
|
}
|
||||||
|
@ -89,11 +89,12 @@ object QUserTask {
|
|||||||
def insert(
|
def insert(
|
||||||
scope: UserTaskScope,
|
scope: UserTaskScope,
|
||||||
subject: Option[String],
|
subject: Option[String],
|
||||||
task: UserTask[String]
|
task: UserTask[String],
|
||||||
|
silent: Boolean
|
||||||
): ConnectionIO[Int] =
|
): ConnectionIO[Int] =
|
||||||
for {
|
for {
|
||||||
r <- task.toPeriodicTask[ConnectionIO](scope, subject)
|
r <- task.toPeriodicTask[ConnectionIO](scope, subject)
|
||||||
n <- RPeriodicTask.insert(r)
|
n <- RPeriodicTask.insert(r, silent)
|
||||||
} yield n
|
} yield n
|
||||||
|
|
||||||
def update(
|
def update(
|
||||||
|
@ -44,7 +44,7 @@ final class UserTaskStoreImpl[F[_]: Sync](
|
|||||||
implicit E: Encoder[A]
|
implicit E: Encoder[A]
|
||||||
): F[Int] = {
|
): F[Int] = {
|
||||||
val exists = QUserTask.exists(ut.id)
|
val exists = QUserTask.exists(ut.id)
|
||||||
val insert = QUserTask.insert(scope, subject, ut.encode)
|
val insert = QUserTask.insert(scope, subject, ut.encode, silent = true)
|
||||||
store.add(insert, exists).flatMap {
|
store.add(insert, exists).flatMap {
|
||||||
case AddResult.Success =>
|
case AddResult.Success =>
|
||||||
1.pure[F]
|
1.pure[F]
|
||||||
@ -101,7 +101,9 @@ final class UserTaskStoreImpl[F[_]: Sync](
|
|||||||
} yield task
|
} yield task
|
||||||
case Nil =>
|
case Nil =>
|
||||||
val task = ut.encode
|
val task = ut.encode
|
||||||
store.transact(QUserTask.insert(scope, subject, task)).map(_ => task)
|
store
|
||||||
|
.transact(QUserTask.insert(scope, subject, task, silent = false))
|
||||||
|
.map(_ => task)
|
||||||
}
|
}
|
||||||
|
|
||||||
def deleteAll(scope: UserTaskScope, name: Ident): F[Int] =
|
def deleteAll(scope: UserTaskScope, name: Ident): F[Int] =
|
||||||
|
@ -115,14 +115,13 @@ object RPeriodicTask {
|
|||||||
def setEnabledByTask(taskName: Ident, enabled: Boolean): ConnectionIO[Int] =
|
def setEnabledByTask(taskName: Ident, enabled: Boolean): ConnectionIO[Int] =
|
||||||
DML.update(T, T.task === taskName, DML.set(T.enabled.setTo(enabled)))
|
DML.update(T, T.task === taskName, DML.set(T.enabled.setTo(enabled)))
|
||||||
|
|
||||||
def insert(v: RPeriodicTask): ConnectionIO[Int] =
|
def insert(v: RPeriodicTask, silent: Boolean): ConnectionIO[Int] = {
|
||||||
DML.insert(
|
val values = fr"${v.id},${v.enabled},${v.task},${v.group},${v.args}," ++
|
||||||
T,
|
fr"${v.subject},${v.submitter},${v.priority},${v.worker}," ++
|
||||||
T.all,
|
fr"${v.marked},${v.timer},${v.nextrun},${v.created},${v.summary}"
|
||||||
fr"${v.id},${v.enabled},${v.task},${v.group},${v.args}," ++
|
if (silent) DML.insertSilent(T, T.all, values)
|
||||||
fr"${v.subject},${v.submitter},${v.priority},${v.worker}," ++
|
else DML.insert(T, T.all, values)
|
||||||
fr"${v.marked},${v.timer},${v.nextrun},${v.created},${v.summary}"
|
}
|
||||||
)
|
|
||||||
|
|
||||||
def update(v: RPeriodicTask): ConnectionIO[Int] =
|
def update(v: RPeriodicTask): ConnectionIO[Int] =
|
||||||
DML.update(
|
DML.update(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user