Skip to content

Commit

Permalink
fix: faulty mime type detection
Browse files Browse the repository at this point in the history
  • Loading branch information
NurMarvin committed Nov 12, 2023
1 parent 7a9b880 commit 926d787
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.gradle
Expand Up @@ -114,6 +114,7 @@ dependencies {
implementation 'io.netty:netty-handler-proxy:4.1.82.Final'

implementation 'com.vdurmont:semver4j:3.1.0'
implementation 'org.apache.tika:tika-core:2.9.1'

// Test libraries

Expand Down
Expand Up @@ -21,6 +21,7 @@ package net.ccbluex.liquidbounce.base.ultralight.impl
import com.labymedia.ultralight.plugin.filesystem.UltralightFileSystem
import net.ccbluex.liquidbounce.LiquidBounce.logger
import net.ccbluex.liquidbounce.base.ultralight.UltralightEngine
import org.apache.tika.Tika
import java.io.File
import java.io.IOException
import java.nio.ByteBuffer
Expand All @@ -31,6 +32,8 @@ import java.nio.file.*
* Ultralight browser file system
*/
class BrowserFileSystem : UltralightFileSystem {
private val tika = Tika()


// Dumb implementation of a counter, but this will probably always be enough...
// unless you have 9,223,372,036,854,775,807 files open. Please reconsider your application then!
Expand Down Expand Up @@ -97,7 +100,7 @@ class BrowserFileSystem : UltralightFileSystem {
}
return try {
// Retrieve the mime type and log it
val mimeType = Files.probeContentType(realPath)
val mimeType = tika.detect(realPath)
log(false, "Mime type of %s is %s", path, mimeType)
mimeType
} catch (e: IOException) {
Expand Down Expand Up @@ -244,7 +247,7 @@ class BrowserFileSystem : UltralightFileSystem {
if (error) {
logger.error("[ERROR/FileSystem] $message")
} else {
logger.debug("[INFO/FileSystem] $message")
logger.info("[INFO/FileSystem] $message")
}
}
}

0 comments on commit 926d787

Please sign in to comment.