mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Fix storing empty-trash task
It was wrongly stored using RPeriodicTask directly, but the higher level `UserTask` must be used instead, because this ensures a correctly scoped periodic task using the `updateOneTask` method. Since this is a system task, it can be given a fixed ID which makes it now safe even if stored using RPeriodicTask directly. The bug resulted in multiple empty-trash tasks to be inserted (on each restart). Refs: #347
This commit is contained in:
@ -25,6 +25,8 @@ case class EmptyTrashArgs(
|
||||
def makeSubject: String =
|
||||
s"Empty Trash: Remove older than ${minAge.toJava}"
|
||||
|
||||
def periodicTaskId: Ident =
|
||||
EmptyTrashArgs.periodicTaskId(collective)
|
||||
}
|
||||
|
||||
object EmptyTrashArgs {
|
||||
@ -33,6 +35,9 @@ object EmptyTrashArgs {
|
||||
|
||||
val defaultSchedule = CalEvent.unsafe("*-*-1/7 03:00:00")
|
||||
|
||||
def periodicTaskId(coll: Ident): Ident =
|
||||
Ident.unsafe(s"docspell") / taskName / coll
|
||||
|
||||
implicit val jsonEncoder: Encoder[EmptyTrashArgs] =
|
||||
deriveEncoder[EmptyTrashArgs]
|
||||
implicit val jsonDecoder: Decoder[EmptyTrashArgs] =
|
||||
|
Reference in New Issue
Block a user