Commit 984e75ae authored by Mygod's avatar Mygod

Fix incorrect handling of default values on database upgrade

parent 3cc1a160
...@@ -116,6 +116,7 @@ class ShadowsocksNatService extends BaseService { ...@@ -116,6 +116,7 @@ class ShadowsocksNatService extends BaseService {
} }
def startKcptunDaemon() { def startKcptunDaemon() {
if (profile.kcpcli == null) profile.kcpcli = ""
val cmd = new ArrayBuffer[String] val cmd = new ArrayBuffer[String]
cmd += (getApplicationInfo.dataDir + "/kcptun" cmd += (getApplicationInfo.dataDir + "/kcptun"
......
...@@ -36,10 +36,8 @@ object ShadowsocksSettings { ...@@ -36,10 +36,8 @@ object ShadowsocksSettings {
} }
def updateSummaryEditTextPreference(pref: Preference, value: String) { def updateSummaryEditTextPreference(pref: Preference, value: String) {
if (value != null) { pref.setSummary(value)
pref.setSummary(value) pref.asInstanceOf[SummaryEditTextPreference].setText(value)
pref.asInstanceOf[SummaryEditTextPreference].setText(value)
}
} }
def updateSwitchPreference(pref: Preference, value: Boolean) { def updateSwitchPreference(pref: Preference, value: Boolean) {
......
...@@ -204,6 +204,8 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -204,6 +204,8 @@ class ShadowsocksVpnService extends VpnService with BaseService {
} }
def startKcptunDaemon() { def startKcptunDaemon() {
if (profile.kcpcli == null) profile.kcpcli = ""
val cmd = new ArrayBuffer[String] val cmd = new ArrayBuffer[String]
cmd += (getApplicationInfo.dataDir + "/kcptun" cmd += (getApplicationInfo.dataDir + "/kcptun"
, "-r", profile.host + ":" + profile.kcpPort , "-r", profile.host + ":" + profile.kcpPort
......
...@@ -64,7 +64,7 @@ object DBHelper { ...@@ -64,7 +64,7 @@ object DBHelper {
} }
class DBHelper(val context: Context) class DBHelper(val context: Context)
extends OrmLiteSqliteOpenHelper(context, DBHelper.PROFILE, null, 18) { extends OrmLiteSqliteOpenHelper(context, DBHelper.PROFILE, null, 19) {
import DBHelper._ import DBHelper._
lazy val profileDao: Dao[Profile, Int] = getDao(classOf[Profile]) lazy val profileDao: Dao[Profile, Int] = getDao(classOf[Profile])
...@@ -83,10 +83,11 @@ class DBHelper(val context: Context) ...@@ -83,10 +83,11 @@ class DBHelper(val context: Context)
} }
if (oldVersion < 8) { if (oldVersion < 8) {
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN udpdns SMALLINT;") profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN udpdns SMALLINT;")
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN route VARCHAR;")
} }
if (oldVersion < 9) { if (oldVersion < 9) {
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN route VARCHAR;") profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN route VARCHAR DEFAULT 'all';")
} else if (oldVersion < 19) {
profileDao.executeRawNoArgs("UPDATE `profile` SET route = 'all' WHERE route IS NULL;")
} }
if (oldVersion < 10) { if (oldVersion < 10) {
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN auth SMALLINT;") profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN auth SMALLINT;")
...@@ -128,11 +129,13 @@ class DBHelper(val context: Context) ...@@ -128,11 +129,13 @@ class DBHelper(val context: Context)
if (oldVersion < 17) { if (oldVersion < 17) {
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN kcp SMALLINT;") profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN kcp SMALLINT;")
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN kcpcli VARCHAR;") profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN kcpcli VARCHAR DEFAULT '';")
} }
if (oldVersion < 18) { if (oldVersion < 18) {
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN kcpPort INTEGER;") profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN kcpPort INTEGER DEFAULT 8399;")
} else if (oldVersion < 19) {
profileDao.executeRawNoArgs("UPDATE `profile` SET kcpPort = 8399 WHERE kcpPort = 0;")
} }
} }
} }
......
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