Skip to content

Commit

Permalink
build: update build numbers (#895)
Browse files Browse the repository at this point in the history
fix: migration issues in 1.13.0
  • Loading branch information
hjubb authored May 25, 2022
1 parent aef101f commit 0dbe96d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ dependencies {
testImplementation 'org.robolectric:shadows-multidex:4.4'
}

def canonicalVersionCode = 278
def canonicalVersionName = "1.13.0"
def canonicalVersionCode = 279
def canonicalVersionName = "1.13.1"

def postFixSize = 10
def abiPostFix = ['armeabi-v7a' : 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
INSERT INTO $lastMessageHashValueTable2($snode, $publicKey, $lastMessageHashValue) SELECT $snode, $publicKey, $lastMessageHashValue FROM $legacyLastMessageHashValueTable2);
DROP TABLE $legacyLastMessageHashValueTable2;
"""
const val INSERT_LAST_HASH_DATA = "INSERT OR IGNORE INTO $lastMessageHashValueTable2($snode, $publicKey, $lastMessageHashValue) SELECT $snode, $publicKey, $lastMessageHashValue FROM $legacyLastMessageHashValueTable2;"
const val DROP_LEGACY_LAST_HASH = "DROP TABLE $legacyLastMessageHashValueTable2;"

const val UPDATE_RECEIVED_INCLUDE_NAMESPACE_COMMAND = """
CREATE TABLE IF NOT EXISTS $receivedMessageHashValuesTable(
$publicKey STRING, $receivedMessageHashValues TEXT, $receivedMessageHashNamespace INTEGER DEFAULT 0, PRIMARY KEY ($publicKey, $receivedMessageHashNamespace)
Expand All @@ -122,6 +125,8 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
DROP TABLE $legacyReceivedMessageHashValuesTable3;
"""
const val INSERT_RECEIVED_HASHES_DATA = "INSERT OR IGNORE INTO $receivedMessageHashValuesTable($publicKey, $receivedMessageHashValues) SELECT $publicKey, $receivedMessageHashValues FROM $legacyReceivedMessageHashValuesTable3;"
const val DROP_LEGACY_RECEIVED_HASHES = "DROP TABLE $legacyReceivedMessageHashValuesTable3;"

// region Deprecated
private val deviceLinkCache = "loki_pairing_authorisation_cache"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
private static final int lokiV31 = 52;
private static final int lokiV32 = 53;
private static final int lokiV33 = 54;
private static final int lokiV34 = 55;

// Loki - onUpgrade(...) must be updated to use Loki version numbers if Signal makes any database changes
private static final int DATABASE_VERSION = lokiV33;
private static final int DATABASE_VERSION = lokiV34;
private static final String DATABASE_NAME = "signal.db";

private final Context context;
Expand Down Expand Up @@ -148,6 +149,10 @@ public void onCreate(SQLiteDatabase db) {
db.execSQL(LokiAPIDatabase.CREATE_DEFAULT_FORK_INFO_COMMAND);
db.execSQL(LokiAPIDatabase.UPDATE_HASHES_INCLUDE_NAMESPACE_COMMAND);
db.execSQL(LokiAPIDatabase.UPDATE_RECEIVED_INCLUDE_NAMESPACE_COMMAND);
db.execSQL(LokiAPIDatabase.INSERT_LAST_HASH_DATA);
db.execSQL(LokiAPIDatabase.DROP_LEGACY_LAST_HASH);
db.execSQL(LokiAPIDatabase.INSERT_RECEIVED_HASHES_DATA);
db.execSQL(LokiAPIDatabase.DROP_LEGACY_RECEIVED_HASHES);

executeStatements(db, SmsDatabase.CREATE_INDEXS);
executeStatements(db, MmsDatabase.CREATE_INDEXS);
Expand Down Expand Up @@ -349,6 +354,13 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL(LokiAPIDatabase.UPDATE_RECEIVED_INCLUDE_NAMESPACE_COMMAND);
}

if (oldVersion < lokiV34) {
db.execSQL(LokiAPIDatabase.INSERT_LAST_HASH_DATA);
db.execSQL(LokiAPIDatabase.DROP_LEGACY_LAST_HASH);
db.execSQL(LokiAPIDatabase.INSERT_RECEIVED_HASHES_DATA);
db.execSQL(LokiAPIDatabase.DROP_LEGACY_RECEIVED_HASHES);
}

db.setTransactionSuccessful();
} finally {
db.endTransaction();
Expand Down

0 comments on commit 0dbe96d

Please sign in to comment.