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