diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/model/Media.kt b/komga/src/main/kotlin/org/gotson/komga/domain/model/Media.kt index 909a453b1..f5442e94d 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/model/Media.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/model/Media.kt @@ -38,7 +38,7 @@ class Media( var thumbnail: ByteArray? = null, pages: Iterable = emptyList() -) { +) : AuditableEntity() { @Id @GeneratedValue @Column(name = "id", nullable = false, unique = true) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/web/rest/BookController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/web/rest/BookController.kt index e07eb693e..a69b8e8fd 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/web/rest/BookController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/web/rest/BookController.kt @@ -238,7 +238,7 @@ class BookController( ).lastModified(getBookLastModified(book)) private fun getBookLastModified(book: Book) = - book.fileLastModified.toInstant(ZoneOffset.UTC).toEpochMilli() + book.media.lastModifiedDate!!.toInstant(ZoneOffset.UTC).toEpochMilli() private fun getMediaTypeOrDefault(mediaTypeString: String?): MediaType { diff --git a/komga/src/main/resources/db/migration/V20200103170613__media_as_auditable_entity.sql b/komga/src/main/resources/db/migration/V20200103170613__media_as_auditable_entity.sql new file mode 100644 index 000000000..f7f3d7d14 --- /dev/null +++ b/komga/src/main/resources/db/migration/V20200103170613__media_as_auditable_entity.sql @@ -0,0 +1,13 @@ +alter table media + add (created_date timestamp); +alter table media + add (last_modified_date timestamp); + +update media +set created_date = CURRENT_TIMESTAMP(), + last_modified_date = CURRENT_TIMESTAMP(); + +alter table media + alter column created_date set not null; +alter table media + alter column last_modified_date set not null;