Fix usage of deprecated functions (#1192)

* Fix usage of deprecated functions

* lint

* Lint

* Another
This commit is contained in:
Mitchell Syer
2024-12-07 23:56:42 -05:00
committed by GitHub
parent 1d541a30ae
commit 2e3af25dd4
10 changed files with 37 additions and 36 deletions
@@ -97,7 +97,7 @@ class ApolloSubscriptionProtocolHandler(
try {
objectMapper.readValue(payload)
} catch (exception: Exception) {
logger.error("Error parsing the subscription message", exception)
logger.error(exception) { "Error parsing the subscription message" }
null
}
@@ -106,13 +106,13 @@ class ApolloSubscriptionProtocolHandler(
context: WsContext,
): Flow<SubscriptionOperationMessage> {
if (operationMessage.id == null) {
logger.error("GraphQL subscription operation id is required")
logger.error { "GraphQL subscription operation id is required" }
return flowOf(basicConnectionErrorMessage)
}
if (sessionState.doesOperationExist(operationMessage)) {
sessionState.terminateSession(context, CloseStatus(4409, "Subscriber for ${operationMessage.id} already exists"))
logger.info("Already subscribed to operation ${operationMessage.id} for session ${context.sessionId()}")
logger.info { "Already subscribed to operation ${operationMessage.id} for session ${context.sessionId()}" }
return emptyFlow()
}
@@ -120,7 +120,7 @@ class ApolloSubscriptionProtocolHandler(
val payload = operationMessage.payload
if (payload == null) {
logger.error("GraphQL subscription payload was null instead of a GraphQLRequest object")
logger.error { "GraphQL subscription payload was null instead of a GraphQLRequest object" }
return flowOf(SubscriptionOperationMessage(type = GQL_ERROR.type, id = operationMessage.id))
}
@@ -137,7 +137,7 @@ class ApolloSubscriptionProtocolHandler(
}.onCompletion { if (it == null) emitAll(onComplete(operationMessage)) }
.onStart { sessionState.saveOperation(context, operationMessage, currentCoroutineContext().job) }
} catch (exception: Exception) {
logger.error("Error running graphql subscription", exception)
logger.error(exception) { "Error running graphql subscription" }
// Do not terminate the session, just stop the operation messages
sessionState.completeOperation(operationMessage)
return flowOf(SubscriptionOperationMessage(type = GQL_ERROR.type, id = operationMessage.id))
@@ -168,19 +168,19 @@ class ApolloSubscriptionProtocolHandler(
private fun onPing(): Flow<SubscriptionOperationMessage> = flowOf(pongMessage)
private fun onDisconnect(context: WsContext): Flow<SubscriptionOperationMessage> {
logger.debug("Session \"${context.sessionId()}\" disconnected")
logger.debug { "Session \"${context.sessionId()}\" disconnected" }
sessionState.terminateSession(context, CloseStatus(1000, "Normal Closure"))
return emptyFlow()
}
private fun onUnknownOperation(operationMessage: SubscriptionOperationMessage): Flow<SubscriptionOperationMessage> {
logger.error("Unknown subscription operation $operationMessage")
logger.error { "Unknown subscription operation $operationMessage" }
sessionState.completeOperation(operationMessage)
return emptyFlow()
}
private fun onException(exception: Exception): Flow<SubscriptionOperationMessage> {
logger.error("Error parsing the subscription message", exception)
logger.error(exception) { "Error parsing the subscription message" }
return flowOf(basicConnectionErrorMessage)
}
}
@@ -66,7 +66,8 @@ object Page {
.selectAll()
.where { (PageTable.chapter eq chapterId) }
.orderBy(PageTable.index to SortOrder.ASC)
.limit(1, index.toLong())
.limit(1)
.offset(index.toLong())
.first()
}
val tachiyomiPage =
@@ -146,7 +146,7 @@ class Downloader(
}
finishDownload(downloadLogger, download)
} catch (e: CancellationException) {
logger.debug("Downloader was stopped")
logger.debug { "Downloader was stopped" }
availableSourceDownloads.filter { it.state == Downloading }.forEach { it.state = Queued }
notifier(false, DownloadUpdate(STOPPED, download))
} catch (e: PauseDownloadException) {
@@ -154,7 +154,7 @@ class Downloader(
download.state = Queued
notifier(false, DownloadUpdate(PAUSED, download))
} catch (e: Exception) {
downloadLogger.warn("failed due to", e)
downloadLogger.warn(e) { "failed due to" }
download.tries++
download.state = Error
notifier(false, DownloadUpdate(ERROR, download))
@@ -54,7 +54,7 @@ object Extension {
private val applicationDirs: ApplicationDirs by injectLazy()
suspend fun installExtension(pkgName: String): Int {
logger.debug("Installing $pkgName")
logger.debug { "Installing $pkgName" }
val extensionRecord = extensionTableAsDataClass().first { it.pkgName == pkgName }
return installAPK {
@@ -144,7 +144,7 @@ object Extension {
val className =
packageInfo.packageName + packageInfo.applicationInfo.metaData.getString(METADATA_SOURCE_CLASS)
logger.debug("Main class for extension is $className")
logger.debug { "Main class for extension is $className" }
dex2jar(apkFilePath, jarFilePath, fileNameWithoutType)
extractAssetsFromApk(apkFilePath, jarFilePath)
@@ -295,7 +295,7 @@ object Extension {
}
fun uninstallExtension(pkgName: String) {
logger.debug("Uninstalling $pkgName")
logger.debug { "Uninstalling $pkgName" }
val extensionRecord = transaction { ExtensionTable.selectAll().where { ExtensionTable.pkgName eq pkgName }.first() }
val fileNameWithoutType = extensionRecord[ExtensionTable.apkName].substringBefore(".apk")
@@ -55,12 +55,12 @@ object ExtensionsList {
suspend fun fetchExtensionsCached() {
// update if 60 seconds has passed or requested offline and database is empty
if (lastUpdateCheck + 60.seconds.inWholeMilliseconds < System.currentTimeMillis()) {
logger.debug("Getting extensions list from the internet")
logger.debug { "Getting extensions list from the internet" }
lastUpdateCheck = System.currentTimeMillis()
fetchExtensions()
} else {
logger.debug("used cached extension list")
logger.debug { "used cached extension list" }
}
}
@@ -69,7 +69,7 @@ object PackageTools {
.to(jarFilePath)
if (handler.hasException()) {
val errorFile: Path = File(applicationDirs.extensionsRoot).toPath().resolve("$fileNameWithoutType-error.txt")
logger.error(
logger.error {
"""
Detail Error Information in File $errorFile
Please report this file to one of following link if possible (any one).
@@ -77,8 +77,8 @@ object PackageTools {
https://bitbucket.org/pxb1988/dex2jar/issues
https://github.com/pxb1988/dex2jar/issues
dex2jar@googlegroups.com
""".trimIndent(),
)
""".trimIndent()
}
handler.dump(errorFile, emptyArray<String>())
} else {
BytecodeEditor.fixAndroidClasses(jarFilePath)
@@ -97,7 +97,7 @@ object PackageTools {
dBuilder.parse(it)
}
logger.trace(parsed.manifestXml)
logger.trace { parsed.manifestXml }
applicationInfo.metaData =
Bundle().apply {
@@ -137,21 +137,21 @@ object JavalinSetup {
)
app.exception(NullPointerException::class.java) { e, ctx ->
logger.error("NullPointerException while handling the request", e)
logger.error(e) { "NullPointerException while handling the request" }
ctx.status(404)
}
app.exception(NoSuchElementException::class.java) { e, ctx ->
logger.error("NoSuchElementException while handling the request", e)
logger.error(e) { "NoSuchElementException while handling the request" }
ctx.status(404)
}
app.exception(IOException::class.java) { e, ctx ->
logger.error("IOException while handling the request", e)
logger.error(e) { "IOException while handling the request" }
ctx.status(500)
ctx.result(e.message ?: "Internal Server Error")
}
app.exception(IllegalArgumentException::class.java) { e, ctx ->
logger.error("IllegalArgumentException while handling the request", e)
logger.error(e) { "IllegalArgumentException while handling the request" }
ctx.status(400)
ctx.result(e.message ?: "Bad Request")
}
@@ -137,7 +137,7 @@ fun applicationSetup() {
setupLogLevelUpdating(serverConfig.debugLogsEnabled, listOf(BASE_LOGGER_NAME))
logger.info("Running Suwayomi-Server ${BuildConfig.VERSION} revision ${BuildConfig.REVISION}")
logger.info { "Running Suwayomi-Server ${BuildConfig.VERSION} revision ${BuildConfig.REVISION}" }
logger.debug {
"Loaded config:\n" +
@@ -202,7 +202,7 @@ fun applicationSetup() {
GlobalConfigManager.updateUserConfig()
}
} catch (e: Exception) {
logger.error("Exception while creating initial server.conf", e)
logger.error(e) { "Exception while creating initial server.conf" }
}
// copy local source icon
@@ -216,7 +216,7 @@ fun applicationSetup() {
}
}
} catch (e: Exception) {
logger.error("Exception while copying Local source's icon", e)
logger.error(e) { "Exception while copying Local source's icon" }
}
// fixes #119 , ref: https://github.com/Suwayomi/Suwayomi-Server/issues/119#issuecomment-894681292 , source Id calculation depends on String.lowercase()
@@ -265,9 +265,9 @@ fun applicationSetup() {
)
}.distinctUntilChanged(),
{ (proxyEnabled, proxyVersion, proxyHost, proxyPort, proxyUsername, proxyPassword) ->
logger.info(
"Socks Proxy changed - enabled=$proxyEnabled address=$proxyHost:$proxyPort , username=$proxyUsername, password=[REDACTED]",
)
logger.info {
"Socks Proxy changed - enabled=$proxyEnabled address=$proxyHost:$proxyPort , username=$proxyUsername, password=[REDACTED]"
}
if (proxyEnabled) {
System.setProperty("socksProxyHost", proxyHost)
System.setProperty("socksProxyPort", proxyPort)
@@ -22,7 +22,7 @@ enum class ExitCode(
}
fun shutdownApp(exitCode: ExitCode) {
logger.info("Shutting Down Suwayomi-Server. Goodbye!")
logger.info { "Shutting Down Suwayomi-Server. Goodbye!" }
exitProcess(exitCode.code)
}
@@ -70,20 +70,20 @@ object AppMutex {
fun handleAppMutex() {
when (checkAppMutex()) {
AppMutexState.Clear -> {
logger.info("Mutex status is clear, Resuming startup.")
logger.info { "Mutex status is clear, Resuming startup." }
}
AppMutexState.TachideskInstanceRunning -> {
logger.info("Another instance of Suwayomi-Server is running on $appIP:${serverConfig.port.value}")
logger.info { "Another instance of Suwayomi-Server is running on $appIP:${serverConfig.port.value}" }
logger.info("Probably user thought Suwayomi-Server is closed so, opening webUI in browser again.")
logger.info { "Probably user thought Suwayomi-Server is closed so, opening webUI in browser again." }
openInBrowser()
logger.info("Aborting startup.")
logger.info { "Aborting startup." }
shutdownApp(MutexCheckFailedTachideskRunning)
}
AppMutexState.OtherApplicationRunning -> {
logger.error("A non Suwayomi-Server application is running on $appIP:${serverConfig.port.value}, aborting startup.")
logger.error { "A non Suwayomi-Server application is running on $appIP:${serverConfig.port.value}, aborting startup." }
shutdownApp(MutexCheckFailedAnotherAppRunning)
}
}