Make sure to only remove/retry items in premature states

This commit is contained in:
Eike Kettner
2020-10-26 22:02:31 +01:00
parent dd89e05cc2
commit b59696a9d3
3 changed files with 25 additions and 12 deletions

View File

@ -121,9 +121,10 @@ object CreateItem {
private def findExisting[F[_]: Sync]: Task[F, ProcessItemArgs, Option[ItemData]] =
Task { ctx =>
val states = ItemState.invalidStates.toList.toSet
val fileMetaIds = ctx.args.files.map(_.fileMetaId).toSet
for {
cand <- ctx.store.transact(QItem.findByFileIds(fileMetaIds.toSeq))
cand <- ctx.store.transact(QItem.findByFileIds(fileMetaIds.toSeq, states))
_ <-
if (cand.nonEmpty)
ctx.logger.warn(s"Found ${cand.size} existing item with these files.")

View File

@ -103,10 +103,13 @@ object ItemHandler {
)
}
def deleteByFileIds[F[_]: Sync: ContextShift]: Task[F, Args, Unit] =
private def deleteByFileIds[F[_]: Sync: ContextShift]: Task[F, Args, Unit] =
Task { ctx =>
val states = ItemState.invalidStates.toList.toSet
for {
items <- ctx.store.transact(QItem.findByFileIds(ctx.args.files.map(_.fileMetaId)))
items <- ctx.store.transact(
QItem.findByFileIds(ctx.args.files.map(_.fileMetaId), states)
)
_ <-
if (items.nonEmpty) ctx.logger.info(s"Deleting items ${items.map(_.id.id)}")
else