Rename mimetype check

This commit is contained in:
AviKav 2020-07-14 03:59:07 -04:00
parent 0caa1f00a6
commit 80402f3c52
No known key found for this signature in database
GPG key ID: 7BC4B96BC8A7167D

View file

@ -144,7 +144,7 @@ class ImageServer(
// TODO: Cleanup messy conditionals
// Ensure that cached file isn't a non-image from the Great Cache Propagation
val flaresFault = imageDatum != null && imageDatum.contentType.isImage().not()
val flaresFault = imageDatum != null && imageDatum.contentType.isImageMimetype().not()
if (flaresFault) {
snapshot?.close(); snapshot = null
@ -181,7 +181,7 @@ class ImageServer(
}
}
private fun String.isImage() = this.toLowerCase().startsWith("image/")
private fun String.isImageMimetype() = this.toLowerCase().startsWith("image/")
private fun Request.handleCacheHit(sanitizedUri: String, cipher: Cipher, snapshot: DiskLruCache.Snapshot, imageDatum: ImageDatum): Response {
// our files never change, so it's safe to use the browser cache
@ -233,8 +233,8 @@ class ImageServer(
contentType!!
if (!contentType.isImage()) {
LOGGER.trace { "Upstream query for $sanitizedUri returned bad mime-type $contentType" }
if (!contentType.isImageMimetype()) {
LOGGER.trace { "Upstream query for $sanitizedUri returned bad mimetype $contentType" }
mdResponse.close()
return Response(mdResponse.status)
}