Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Commit 101e009

Browse files
committed
prettify some code ;-D
1 parent 800ff3a commit 101e009

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

topl-service/src/main/java/io/matthewnelson/topl_service/onionproxy/OnionProxyInstaller.kt

+8-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import java.util.concurrent.TimeoutException
1717
*
1818
* @param [torService] for context.
1919
* @param [torConfigFiles] [TorConfigFiles] to know where files/directories are.
20-
* @param [appVersionCode] Mitigate copying of geoip files to app updates only. Use [BuildConfig.VERSION_CODE].
20+
* @param [buildConfigVersionCode] Mitigate copying of geoip files to app updates only. Use [BuildConfig.VERSION_CODE].
2121
* @param [geoIpAssetPath] The path to geoip file within the application, ex: "common/geoip"
2222
* @param [geoIp6AssetPath] The path to geoip6 file within the application, ex: "common/geoip6"
2323
*
@@ -26,7 +26,7 @@ import java.util.concurrent.TimeoutException
2626
internal class OnionProxyInstaller(
2727
private val torService: TorService,
2828
private val torConfigFiles: TorConfigFiles,
29-
private val appVersionCode: Int,
29+
private val buildConfigVersionCode: Int,
3030
private val geoIpAssetPath: String,
3131
private val geoIp6AssetPath: String
3232
): TorInstaller() {
@@ -45,13 +45,16 @@ internal class OnionProxyInstaller(
4545
geoIp6FileCoppied = ""
4646

4747
// If the app version has been increased, or if this is a debug build of topl-service
48-
// module, copy over geoip assets then update SharedPreferences with the new appVersion
49-
if (appVersionCode > prefs.getInt("APP_VERSION", -1) ?: -1 || BuildConfig.DEBUG) {
48+
// module, copy over geoip assets then update SharedPreferences with the updated
49+
// version code. Mitigates copying to be done only if a version upgrade is had.
50+
if (buildConfigVersionCode > prefs.getInt("BUILD_CONFIG_VERSION_CODE", -1) ?: -1 ||
51+
BuildConfig.DEBUG
52+
) {
5053
if (!::geoIpFileCoppied.isInitialized)
5154
copyAsset(geoIpAssetPath, torConfigFiles.geoIpFile)
5255
if (!::geoIp6FileCoppied.isInitialized)
5356
copyAsset(geoIp6AssetPath, torConfigFiles.geoIpv6File)
54-
prefs.putInt("APP_VERSION", appVersionCode)
57+
prefs.putInt("BUILD_CONFIG_VERSION_CODE", buildConfigVersionCode)
5558
}
5659
}
5760

0 commit comments

Comments
 (0)