mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Make sure the empty-trash task is started for all collectives
This commit is contained in:
@ -7,11 +7,9 @@
|
||||
package docspell.joex
|
||||
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
import cats.effect._
|
||||
import cats.implicits._
|
||||
import fs2.concurrent.SignallingRef
|
||||
|
||||
import docspell.analysis.TextAnalyser
|
||||
import docspell.backend.ops._
|
||||
import docspell.common._
|
||||
@ -34,8 +32,7 @@ import docspell.joex.scheduler._
|
||||
import docspell.joexapi.client.JoexClient
|
||||
import docspell.store.Store
|
||||
import docspell.store.queue._
|
||||
import docspell.store.records.RJobLog
|
||||
|
||||
import docspell.store.records.{REmptyTrashSetting, RJobLog}
|
||||
import emil.javamail._
|
||||
import org.http4s.blaze.client.BlazeClientBuilder
|
||||
import org.http4s.client.Client
|
||||
@ -77,11 +74,23 @@ final class JoexAppImpl[F[_]: Async](
|
||||
HouseKeepingTask
|
||||
.periodicTask[F](cfg.houseKeeping.schedule)
|
||||
.flatMap(pstore.insert) *>
|
||||
scheduleEmptyTrashTasks *>
|
||||
MigrationTask.job.flatMap(queue.insertIfNew) *>
|
||||
AllPreviewsTask
|
||||
.job(MakePreviewArgs.StoreMode.WhenMissing, None)
|
||||
.flatMap(queue.insertIfNew) *>
|
||||
AllPageCountTask.job.flatMap(queue.insertIfNew)
|
||||
|
||||
private def scheduleEmptyTrashTasks: F[Unit] =
|
||||
store
|
||||
.transact(
|
||||
REmptyTrashSetting.findForAllCollectives(EmptyTrashArgs.defaultSchedule, 50)
|
||||
)
|
||||
.evalMap(es => EmptyTrashTask.periodicTask(es.cid, es.schedule))
|
||||
.evalMap(pstore.insert)
|
||||
.compile
|
||||
.drain
|
||||
|
||||
}
|
||||
|
||||
object JoexAppImpl {
|
||||
|
@ -8,15 +8,15 @@ package docspell.joex.emptytrash
|
||||
|
||||
import cats.effect._
|
||||
import cats.implicits._
|
||||
import com.github.eikek.calev.CalEvent
|
||||
import fs2.Stream
|
||||
|
||||
import docspell.backend.ops.{OItem, OItemSearch}
|
||||
import docspell.common._
|
||||
import docspell.joex.scheduler._
|
||||
import docspell.store.records.RItem
|
||||
import docspell.store.records.{RItem, RPeriodicTask}
|
||||
import docspell.store.usertask.UserTask
|
||||
|
||||
object EmptyTrashTask {
|
||||
|
||||
type Args = EmptyTrashArgs
|
||||
|
||||
def onCancel[F[_]]: Task[F, Args, Unit] =
|
||||
@ -24,6 +24,19 @@ object EmptyTrashTask {
|
||||
|
||||
private val pageSize = 20
|
||||
|
||||
def periodicTask[F[_]: Sync](collective: Ident, ce: CalEvent): F[RPeriodicTask] = {
|
||||
Ident.randomId[F].flatMap( id =>
|
||||
UserTask(
|
||||
id,
|
||||
EmptyTrashArgs.taskName,
|
||||
true,
|
||||
ce,
|
||||
None,
|
||||
EmptyTrashArgs(collective)
|
||||
).encode.toPeriodicTask(AccountId(collective, collective)))
|
||||
}
|
||||
|
||||
|
||||
def apply[F[_]: Async](
|
||||
itemOps: OItem[F],
|
||||
itemSearchOps: OItemSearch[F]
|
||||
|
Reference in New Issue
Block a user