mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Provide endpoints to submit tasks to re-generate previews
The scaling factor can be given in the config file. When this changes, images can be regenerated via POSTing to certain endpoints. It is possible to regenerate just one attachment preview or all within a collective.
This commit is contained in:
@ -26,9 +26,9 @@ object QAttachment {
|
||||
Stream
|
||||
.evalSeq(store.transact(findPreview))
|
||||
.map(_.fileId.id)
|
||||
.evalTap(_ => store.transact(RAttachmentPreview.delete(attachId)))
|
||||
.flatMap(store.bitpeace.delete)
|
||||
.map(flag => if (flag) 1 else 0)
|
||||
.evalMap(_ => store.transact(RAttachmentPreview.delete(attachId)))
|
||||
.compile
|
||||
.foldMonoid
|
||||
}
|
||||
|
@ -231,6 +231,30 @@ object RAttachment {
|
||||
def findItemId(attachId: Ident): ConnectionIO[Option[Ident]] =
|
||||
selectSimple(Seq(itemId), table, id.is(attachId)).query[Ident].option
|
||||
|
||||
def findAll(
|
||||
coll: Option[Ident],
|
||||
chunkSize: Int
|
||||
): Stream[ConnectionIO, RAttachment] = {
|
||||
val aItem = Columns.itemId.prefix("a")
|
||||
val iId = RItem.Columns.id.prefix("i")
|
||||
val iColl = RItem.Columns.cid.prefix("i")
|
||||
|
||||
val cols = all.map(_.prefix("a"))
|
||||
|
||||
coll match {
|
||||
case Some(cid) =>
|
||||
val join = table ++ fr"a INNER JOIN" ++ RItem.table ++ fr"i ON" ++ iId.is(aItem)
|
||||
val cond = iColl.is(cid)
|
||||
selectSimple(cols, join, cond)
|
||||
.query[RAttachment]
|
||||
.streamWithChunkSize(chunkSize)
|
||||
case None =>
|
||||
selectSimple(cols, table, Fragment.empty)
|
||||
.query[RAttachment]
|
||||
.streamWithChunkSize(chunkSize)
|
||||
}
|
||||
}
|
||||
|
||||
def findWithoutPreview(
|
||||
coll: Option[Ident],
|
||||
chunkSize: Int
|
||||
|
Reference in New Issue
Block a user