From 195f6a54daf903a1a07fe47aaa150c2fe8f80435 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Fri, 14 Jun 2019 10:56:41 -0500 Subject: [PATCH] Update current version after each migration --- .../com/todoroo/astrid/service/Upgrader.java | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/todoroo/astrid/service/Upgrader.java b/app/src/main/java/com/todoroo/astrid/service/Upgrader.java index ae0ff879e..2f4e2ef0d 100644 --- a/app/src/main/java/com/todoroo/astrid/service/Upgrader.java +++ b/app/src/main/java/com/todoroo/astrid/service/Upgrader.java @@ -78,32 +78,25 @@ public class Upgrader { public void upgrade(int from, int to) { if (from > 0) { - if (from < V4_8_0) { - performMarshmallowMigration(); - } - if (from < V4_9_5) { - removeDuplicateTags(); - } - if (from < V5_3_0) { - migrateFilters(); - } - if (from < V6_0_beta_1) { - migrateDefaultSyncList(); - } - if (from < V6_0_beta_2) { - migrateGoogleTaskAccount(); - } - if (from < V6_4) { - migrateUris(); - } - if (from < V6_7) { - migrateGoogleTaskFilters(); - } + run(from, V4_8_0, this::performMarshmallowMigration); + run(from, V4_9_5, this::removeDuplicateTags); + run(from, V5_3_0, this::migrateFilters); + run(from, V6_0_beta_1, this::migrateDefaultSyncList); + run(from, V6_0_beta_2, this::migrateGoogleTaskAccount); + run(from, V6_4, this::migrateUris); + run(from, V6_7, this::migrateGoogleTaskFilters); tracker.reportEvent(Tracking.Events.UPGRADE, Integer.toString(from)); } preferences.setCurrentVersion(to); } + private void run(int from, int version, Runnable runnable) { + if (from < version) { + runnable.run(); + preferences.setCurrentVersion(version); + } + } + private void performMarshmallowMigration() { try { // preserve pre-marshmallow default backup location