mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-28 17:55:06 +00:00
Fix deleting attachments (again)
This commit is contained in:
parent
d937e0501a
commit
661cc3e65f
@ -15,21 +15,25 @@ object QAttachment {
|
||||
def deleteById[F[_]: Sync](store: Store[F])(attachId: Ident, coll: Ident): F[Int] =
|
||||
for {
|
||||
raFile <- store.transact(RAttachment.findByIdAndCollective(attachId, coll)).map(_.map(_.fileId))
|
||||
rsFile <- store.transact(RAttachmentSource.findById(attachId)).map(_.map(_.fileId))
|
||||
rsFile <- store.transact(RAttachmentSource.findByIdAndCollective(attachId, coll)).map(_.map(_.fileId))
|
||||
n <- store.transact(RAttachment.delete(attachId))
|
||||
f <- Stream.emits(raFile.toSeq ++ rsFile.toSeq)
|
||||
.map(_.id)
|
||||
.flatMap(store.bitpeace.delete)
|
||||
.map(flag => if (flag) 1 else 0)
|
||||
.compile
|
||||
.last
|
||||
} yield n + f.getOrElse(0)
|
||||
.foldMonoid
|
||||
} yield n + f
|
||||
|
||||
def deleteAttachment[F[_]: Sync](store: Store[F])(ra: RAttachment): F[Int] =
|
||||
for {
|
||||
s <- store.transact(RAttachmentSource.findById(ra.id))
|
||||
n <- store.transact(RAttachment.delete(ra.id))
|
||||
f <- Stream.emit(ra.fileId.id).flatMap(store.bitpeace.delete).compile.last
|
||||
} yield n + f.map(_ => 1).getOrElse(0)
|
||||
f <- Stream.emits(ra.fileId.id +: s.map(_.fileId.id).toSeq).
|
||||
flatMap(store.bitpeace.delete).
|
||||
map(flag => if (flag) 1 else 0).
|
||||
compile.foldMonoid
|
||||
} yield n + f
|
||||
|
||||
def deleteItemAttachments[F[_]: Sync](store: Store[F])(itemId: Ident, coll: Ident): F[Int] =
|
||||
for {
|
||||
|
Loading…
x
Reference in New Issue
Block a user