-
Notifications
You must be signed in to change notification settings - Fork 6
chore: draft for using geoipdb
from path
#940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
it.assetsDir = assetsDir | ||
// geoipDB may or may not exist in this binding; set via reflection when available | ||
geoIpDB?.let { path -> | ||
// it.geoipDB = path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No desktop support from the start?
} | ||
LaunchedEffect(Unit) { | ||
// Check for GeoIP DB updates in the background | ||
runCatching { dependencies.fetchGeoIpDbUpdates() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need runCatching
if we're already try/catching inside the method. I think we just need to log the failures, but that should be going inside the method.
* Perform a simple HTTP GET and return the raw response body bytes. | ||
* Implemented per-platform to ensure binary-safe downloads. | ||
*/ | ||
expect suspend fun httpGetBytes(url: String): ByteArray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You didn't trust the engine httpDo to fetch a larger file? And you preferred not to use a library like ktor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think this should return a Result<ByteArray, ...>
.
|
||
actual suspend fun httpGetBytes(url: String): ByteArray = | ||
withContext(Dispatchers.IO) { | ||
val connection = (URL(url).openConnection() as HttpURLConnection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The openConnection()
may also throw an IOException
import java.net.HttpURLConnection | ||
import java.net.URL | ||
|
||
actual suspend fun httpGetBytes(url: String): ByteArray = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the desktop implementation slightly different from the Android one? Shouldn't they match?
val ip: String?, | ||
val asn: String?, | ||
val countryCode: String?, | ||
val geoIpdb: String?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to get the geoIpDb from the engine?
val taskLogLevel: TaskLogLevel, | ||
val uploadResults: Boolean, | ||
val proxy: String?, | ||
val geoipDbVersion: String?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we also need to tell the engine what version of the Db?
private fun session(sessionConfig: OonimkallBridge.SessionConfig): OonimkallBridge.Session = bridge.newSession(sessionConfig) | ||
|
||
private fun buildTaskSettings( | ||
private suspend fun buildTaskSettings( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suspend
should not be needed.
null | ||
}, | ||
proxy = getProxyOption().first().value, | ||
geoipDbVersion = getValueForKey(SettingsKey.MMDB_VERSION) as String?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should already be providing the DB path here, instead of having to construct it in multiple places.
private val downloader by lazy { | ||
DownloadFile( | ||
fileSystem = FileSystem.SYSTEM, | ||
fetchBytes = { url -> httpGetBytes(url) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as fetchBytes = ::httpGetBytes,
.
No description provided.