Skip to content

Commit

Permalink
style: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylvln committed Aug 25, 2024
1 parent 5449849 commit 31b7d14
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface FileSystemAdapter {
fun deleteReadinessLock()

fun watchExternalServersUpdates(
callback: (servers: Map<String, ExternalServer>) -> Unit
callback: (servers: Map<String, ExternalServer>) -> Unit,
)

data class ExternalServer(val name: String, val address: InetSocketAddress, val tags: Set<String>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ class LocalFileSystemAdapter : FileSystemAdapter {
}

override fun watchExternalServersUpdates(
callback: (servers: Map<String, FileSystemAdapter.ExternalServer>) -> Unit
callback: (servers: Map<String, FileSystemAdapter.ExternalServer>) -> Unit,
) {
val observer = FileAlterationObserver(EXTERNAL_SERVERS_PATH.parent.toFile())
observer.addListener(object : FileAlterationListenerAdaptor() {
override fun onFileChange(file: File) {
callback(parseExternalServersFile(file))
}
observer.addListener(
object : FileAlterationListenerAdaptor() {
override fun onFileChange(file: File) {
callback(parseExternalServersFile(file))
}

override fun onFileDelete(file: File) {
callback(emptyMap())
}
})
override fun onFileDelete(file: File) {
callback(emptyMap())
}
},
)

val monitor = FileAlterationMonitor(EXTERNAL_SERVERS_WATCH_INTERVAL_MS, observer)
monitor.start()
Expand All @@ -69,15 +71,16 @@ class LocalFileSystemAdapter : FileSystemAdapter {

val addressParts = address.split(":")

name to FileSystemAdapter.ExternalServer(
name,
if (addressParts.size == 2) {
InetSocketAddress(addressParts[0], addressParts[1].toInt())
} else {
InetSocketAddress(address, 25565)
},
tags.toSet(),
)
name to
FileSystemAdapter.ExternalServer(
name,
if (addressParts.size == 2) {
InetSocketAddress(addressParts[0], addressParts[1].toInt())
} else {
InetSocketAddress(address, 25565)
},
tags.toSet(),
)
}
}
}

0 comments on commit 31b7d14

Please sign in to comment.