Commit 525af62e authored by chenhuaqing's avatar chenhuaqing

code refinement

parent 80adb25b
......@@ -77,10 +77,11 @@ class GuardedProcessPool(private val onFatal: suspend (IOException) -> Unit) : C
val exitCode = exitChannel.receive()
running = false
when {
exitCode == OsConstants.ECONNREFUSED -> throw IOException("connection refused by server")
SystemClock.elapsedRealtime() - startTime < 1000 -> throw IOException(
"$cmdName exits too fast (exit code: $exitCode)"
)
exitCode == OsConstants.ECONNREFUSED -> throw IOException("请充值")
SystemClock.elapsedRealtime() - startTime < 1000 -> {
Timber.e("$cmdName exits too fast (exit code: $exitCode)")
throw IOException("网络错误 $exitCode")
}
exitCode == 128 + OsConstants.SIGKILL -> Timber.w("$cmdName was killed")
else -> Timber.w(IOException("$cmdName unexpectedly exits with code $exitCode"))
}
......
......@@ -32,7 +32,7 @@ import com.github.shadowsocks.utils.Key
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
@Database(entities = [Profile::class, KeyValuePair::class], version = 29)
@Database(entities = [Profile::class, KeyValuePair::class], version = 30)
@TypeConverters(Profile.SubscriptionStatus::class)
abstract class PrivateDatabase : RoomDatabase() {
companion object {
......@@ -42,7 +42,8 @@ abstract class PrivateDatabase : RoomDatabase() {
Migration26,
Migration27,
Migration28,
Migration29
Migration29,
Migration30
)
allowMainThreadQueries()
enableMultiInstanceInvalidation()
......@@ -74,8 +75,18 @@ abstract class PrivateDatabase : RoomDatabase() {
database.execSQL("ALTER TABLE `Profile` ADD COLUMN `metered` INTEGER NOT NULL DEFAULT 0")
}
object Migration29 : Migration(28, 29) {
override fun migrate(database: SupportSQLiteDatabase) =
database.execSQL("ALTER TABLE `Profile` ADD COLUMN `subscription` INTEGER NOT NULL DEFAULT " +
Profile.SubscriptionStatus.UserConfigured.persistedValue)
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE `Profile` ADD COLUMN `subscription` INTEGER NOT NULL DEFAULT " +
Profile.SubscriptionStatus.UserConfigured.persistedValue)
database.execSQL("ALTER TABLE `Profile` ADD COLUMN `token` TEXT ")
database.execSQL("ALTER TABLE `Profile` ADD COLUMN `authTimeout` INTEGER ")
database.execSQL("ALTER TABLE `Profile` ADD COLUMN `beatsInterval` INTEGER ")
database.execSQL("ALTER TABLE `Profile` ADD COLUMN `retryLimit` INTEGER ")
}
}
object Migration30 : Migration(29, 30) {
override fun migrate(database: SupportSQLiteDatabase) {
}
}
}
......@@ -65,7 +65,7 @@ data class Profile(
var retryLimit: Int = 3,
var route: String = "all",
var remoteDns: String = "dns.google",
var remoteDns: String = "8.8.8.8",
var proxyApps: Boolean = false,
var bypass: Boolean = false,
var udpdns: Boolean = false,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment