From c10c3ebe1067b798a75bfe95a15f089c73190410 Mon Sep 17 00:00:00 2001 From: Tibor Casteleijn Date: Mon, 30 Dec 2024 09:25:25 +0100 Subject: [PATCH] fix duplicate tasks being inserted when rebooting --- modules/joex/src/main/scala/docspell/joex/JoexAppImpl.scala | 4 ++-- .../scala/docspell/joex/updatecheck/UpdateCheckTask.scala | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/joex/src/main/scala/docspell/joex/JoexAppImpl.scala b/modules/joex/src/main/scala/docspell/joex/JoexAppImpl.scala index ebf57d444c..f2ad679e1d 100644 --- a/modules/joex/src/main/scala/docspell/joex/JoexAppImpl.scala +++ b/modules/joex/src/main/scala/docspell/joex/JoexAppImpl.scala @@ -71,11 +71,11 @@ final class JoexAppImpl[F[_]: Async]( private def scheduleBackgroundTasks: F[Unit] = HouseKeepingTask .periodicTask[F](cfg.houseKeeping.schedule) - .flatMap(t => uts.updateTask(UserTaskScope.system, t.summary, t)) *> + .flatMap(t => uts.updateOneTask(UserTaskScope.system, t.summary, t)) *> scheduleEmptyTrashTasks *> UpdateCheckTask .periodicTask(cfg.updateCheck) - .flatMap(t => uts.updateTask(UserTaskScope.system, t.summary, t)) *> + .flatMap(t => uts.updateOneTask(UserTaskScope.system, t.summary, t)) *> MigrationTask.job.flatMap(jobStore.insertIfNew) *> AllPreviewsTask .job(MakePreviewArgs.StoreMode.WhenMissing, None) diff --git a/modules/joex/src/main/scala/docspell/joex/updatecheck/UpdateCheckTask.scala b/modules/joex/src/main/scala/docspell/joex/updatecheck/UpdateCheckTask.scala index 57ccecaef3..e3fdae84dc 100644 --- a/modules/joex/src/main/scala/docspell/joex/updatecheck/UpdateCheckTask.scala +++ b/modules/joex/src/main/scala/docspell/joex/updatecheck/UpdateCheckTask.scala @@ -20,6 +20,7 @@ import emil._ object UpdateCheckTask { val taskName: Ident = Ident.unsafe("new-release-check") + val periodicId: Ident = Ident.unsafe("docspell-update-check") type Args = Unit @@ -28,7 +29,7 @@ object UpdateCheckTask { def periodicTask[F[_]: Sync](cfg: UpdateCheckConfig): F[UserTask[Unit]] = UserTask( - Ident.unsafe("docspell-update-check"), + periodicId, taskName, cfg.enabled, cfg.schedule,