From 8b0b39cba7b6ce47be499ca4f8dfbe4b67c83862 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Tue, 24 Nov 2015 13:23:16 +0800 Subject: [PATCH] fix #444 --- src/main/res/xml/pref_all.xml | 4 ++-- .../scala/com/github/shadowsocks/Shadowsocks.scala | 14 ++++++++++++++ .../com/github/shadowsocks/database/DBHelper.scala | 7 +++++-- .../com/github/shadowsocks/utils/Constants.scala | 4 ++-- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/res/xml/pref_all.xml b/src/main/res/xml/pref_all.xml index 82412e04..2390e8e3 100644 --- a/src/main/res/xml/pref_all.xml +++ b/src/main/res/xml/pref_all.xml @@ -25,13 +25,13 @@ // Ignore + } } } diff --git a/src/main/scala/com/github/shadowsocks/database/DBHelper.scala b/src/main/scala/com/github/shadowsocks/database/DBHelper.scala index d1aeeca9..ae685307 100644 --- a/src/main/scala/com/github/shadowsocks/database/DBHelper.scala +++ b/src/main/scala/com/github/shadowsocks/database/DBHelper.scala @@ -81,19 +81,22 @@ class DBHelper(val context: Context) profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN ipv6 SMALLINT;") } if (oldVersion < 12) { + profileDao.executeRawNoArgs("BEGIN TRANSACTION;") profileDao.executeRawNoArgs("ALTER TABLE `profile` RENAME TO `tmp`;") - onCreate(database, connectionSource) + TableUtils.createTable(connectionSource, classOf[Profile]) profileDao.executeRawNoArgs( "INSERT INTO `profile`(id, name, host, localPort, remotePort, password, method, route, proxyApps, bypass," + " udpdns, auth, ipv6, individual) " + "SELECT id, name, host, localPort, remotePort, password, method, route, 1 - global, bypass, udpdns, auth," + " ipv6, individual FROM `tmp`;") profileDao.executeRawNoArgs("DROP TABLE `tmp`;") + profileDao.executeRawNoArgs("COMMIT;") + return } if (oldVersion < 13) { profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN tx LONG;") profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN rx LONG;") - profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN date DATE;") + profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN date VARCHAR;") } } } diff --git a/src/main/scala/com/github/shadowsocks/utils/Constants.scala b/src/main/scala/com/github/shadowsocks/utils/Constants.scala index c207e08d..cfc405c9 100644 --- a/src/main/scala/com/github/shadowsocks/utils/Constants.scala +++ b/src/main/scala/com/github/shadowsocks/utils/Constants.scala @@ -82,8 +82,8 @@ object Key { val proxy = "proxy" val sitekey = "sitekey" val encMethod = "encMethod" - val remotePort = "remotePort" - val localPort = "port" + val remotePort = "remotePortNum" + val localPort = "localPortNum" } object Scheme {