Files
Suwayomi-Server/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ImageMutation.kt
renovate[bot] edf376e3dd Update graphqlkotlin to v10 alpha (major) (#1923)
* Update graphqlkotlin to v9

* Update to the v10 alpha due to nullability issues in v9

* Fixes

* Remove asDataFetcherResult

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Syer10 <syer10@users.noreply.github.com>
2026-05-10 19:01:34 -04:00

60 lines
1.9 KiB
Kotlin

@file:Suppress("RedundantNullableReturnType", "unused")
package suwayomi.tachidesk.graphql.mutations
import suwayomi.tachidesk.graphql.directives.RequireAuth
import suwayomi.tachidesk.manga.impl.util.storage.ImageResponse
import suwayomi.tachidesk.server.ApplicationDirs
import uy.kohesive.injekt.injectLazy
private val applicationDirs: ApplicationDirs by injectLazy()
class ImageMutation {
data class ClearCachedImagesInput(
val clientMutationId: String? = null,
val downloadedThumbnails: Boolean? = null,
val cachedThumbnails: Boolean? = null,
val cachedPages: Boolean? = null,
)
data class ClearCachedImagesPayload(
val clientMutationId: String? = null,
val downloadedThumbnails: Boolean?,
val cachedThumbnails: Boolean?,
val cachedPages: Boolean?,
)
@RequireAuth
fun clearCachedImages(input: ClearCachedImagesInput): ClearCachedImagesPayload {
val (clientMutationId, downloadedThumbnails, cachedThumbnails, cachedPages) = input
val downloadedThumbnailsResult =
if (downloadedThumbnails == true) {
ImageResponse.clearImages(applicationDirs.thumbnailDownloadsRoot)
} else {
null
}
val cachedThumbnailsResult =
if (cachedThumbnails == true) {
ImageResponse.clearImages(applicationDirs.tempThumbnailCacheRoot)
} else {
null
}
val cachedPagesResult =
if (cachedPages == true) {
ImageResponse.clearImages(applicationDirs.tempMangaCacheRoot)
} else {
null
}
return ClearCachedImagesPayload(
clientMutationId,
downloadedThumbnails = downloadedThumbnailsResult,
cachedThumbnails = cachedThumbnailsResult,
cachedPages = cachedPagesResult,
)
}
}