mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Make sure to only remove/retry items in premature states
This commit is contained in:
@ -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.")
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user