Merge branch 'repo_archive_switch' into 'master'

Repo archive switch

Closes #1686, #1772, and #1771

See merge request fdroid/fdroidclient!818
This commit is contained in:
Hans-Christoph Steiner 2020-06-24 14:56:23 +00:00
commit a1701ca8c0
2 changed files with 65 additions and 32 deletions

View File

@ -30,6 +30,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.text.TextUtils;
import android.util.Log;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.Utils;
@ -226,7 +227,7 @@ public class DBHelper extends SQLiteOpenHelper {
+ "primary key(" + ApkAntiFeatureJoinTable.Cols.APK_ID + ", " + ApkAntiFeatureJoinTable.Cols.ANTI_FEATURE_ID + ") "
+ " );";
protected static final int DB_VERSION = 82;
protected static final int DB_VERSION = 83;
private final Context context;
@ -454,6 +455,40 @@ public class DBHelper extends SQLiteOpenHelper {
addDisabledMirrorsFields(db, oldVersion);
addIsLocalized(db, oldVersion);
addTranslation(db, oldVersion);
switchRepoArchivePriorities(db, oldVersion);
}
private void switchRepoArchivePriorities(SQLiteDatabase db, int oldVersion) {
if (oldVersion >= 83) {
return;
}
Utils.debugLog(TAG, "Switching default repo and archive priority.");
db.execSQL("UPDATE " + RepoTable.NAME + " SET " + RepoTable.Cols.PRIORITY
+ "= ( SELECT SUM(" + RepoTable.Cols.PRIORITY + ")" + " FROM " + RepoTable.NAME
+ " WHERE " + RepoTable.Cols.ADDRESS + " IN ( 'https://f-droid.org/repo', 'https://f-droid.org/archive')"
+ ") - " + RepoTable.Cols.PRIORITY
+ " WHERE " + RepoTable.Cols.ADDRESS + " IN ( 'https://f-droid.org/repo', 'https://f-droid.org/archive')"
+ " AND 'TRUE' IN (SELECT CASE WHEN a." + RepoTable.Cols.PRIORITY + " = b."
+ RepoTable.Cols.PRIORITY + "-1" + " THEN 'TRUE' ELSE 'FASLE' END"
+ " FROM " + RepoTable.NAME + " AS a INNER JOIN " + RepoTable.NAME
+ " AS b ON a." + RepoTable.Cols.ADDRESS + "= 'https://f-droid.org/repo'"
+ " AND b." + RepoTable.Cols.ADDRESS + "= 'https://f-droid.org/archive'"
+ ")"
);
db.execSQL("UPDATE " + RepoTable.NAME + " SET " + RepoTable.Cols.PRIORITY
+ "= ( SELECT SUM(" + RepoTable.Cols.PRIORITY + ")" + " FROM " + RepoTable.NAME
+ " WHERE " + RepoTable.Cols.ADDRESS + " IN ( 'https://guardianproject.info/fdroid/repo', 'https://guardianproject.info/fdroid/archive')"
+ ") - " + RepoTable.Cols.PRIORITY
+ " WHERE " + RepoTable.Cols.ADDRESS + " IN ( 'https://guardianproject.info/fdroid/repo', 'https://guardianproject.info/fdroid/archive')"
+ " AND 'TRUE' IN (SELECT CASE WHEN a." + RepoTable.Cols.PRIORITY + " = b."
+ RepoTable.Cols.PRIORITY + "-1" + " THEN 'TRUE' ELSE 'FASLE' END"
+ " FROM " + RepoTable.NAME + " AS a INNER JOIN " + RepoTable.NAME + " AS b ON a."
+ RepoTable.Cols.ADDRESS + "= 'https://guardianproject.info/fdroid/repo'"
+ " AND b." + RepoTable.Cols.ADDRESS + "= 'https://guardianproject.info/fdroid/archive'"
+ ")"
);
}
private void addTranslation(SQLiteDatabase db, int oldVersion) {

View File

@ -3,28 +3,6 @@
<string-array name="default_repos">
<!-- name -->
<item>F-Droid</item>
<!-- address -->
<item>https://f-droid.org/repo</item>
<!-- description -->
<item>The official F-Droid repository. Applications in this repository are mostly built
directory from the source code. Some are official binaries built by the original
application developers - these will be replaced by source-built versions over time.
</item>
<!-- version -->
<item>13</item>
<!-- enabled -->
<item>1</item>
<!-- priority -->
<item>1</item>
<!-- push requests -->
<item>ignore</item>
<!-- pubkey -->
<item>
3082035e30820246a00302010202044c49cd00300d06092a864886f70d01010505003071310b300906035504061302554b3110300e06035504081307556e6b6e6f776e3111300f0603550407130857657468657262793110300e060355040a1307556e6b6e6f776e3110300e060355040b1307556e6b6e6f776e311930170603550403131043696172616e2047756c746e69656b73301e170d3130303732333137313032345a170d3337313230383137313032345a3071310b300906035504061302554b3110300e06035504081307556e6b6e6f776e3111300f0603550407130857657468657262793110300e060355040a1307556e6b6e6f776e3110300e060355040b1307556e6b6e6f776e311930170603550403131043696172616e2047756c746e69656b7330820122300d06092a864886f70d01010105000382010f003082010a028201010096d075e47c014e7822c89fd67f795d23203e2a8843f53ba4e6b1bf5f2fd0e225938267cfcae7fbf4fe596346afbaf4070fdb91f66fbcdf2348a3d92430502824f80517b156fab00809bdc8e631bfa9afd42d9045ab5fd6d28d9e140afc1300917b19b7c6c4df4a494cf1f7cb4a63c80d734265d735af9e4f09455f427aa65a53563f87b336ca2c19d244fcbba617ba0b19e56ed34afe0b253ab91e2fdb1271f1b9e3c3232027ed8862a112f0706e234cf236914b939bcf959821ecb2a6c18057e070de3428046d94b175e1d89bd795e535499a091f5bc65a79d539a8d43891ec504058acb28c08393b5718b57600a211e803f4a634e5c57f25b9b8c4422c6fd90203010001300d06092a864886f70d0101050500038201010008e4ef699e9807677ff56753da73efb2390d5ae2c17e4db691d5df7a7b60fc071ae509c5414be7d5da74df2811e83d3668c4a0b1abc84b9fa7d96b4cdf30bba68517ad2a93e233b042972ac0553a4801c9ebe07bf57ebe9a3b3d6d663965260e50f3b8f46db0531761e60340a2bddc3426098397fda54044a17e5244549f9869b460ca5e6e216b6f6a2db0580b480ca2afe6ec6b46eedacfa4aa45038809ece0c5978653d6c85f678e7f5a2156d1bedd8117751e64a4b0dcd140f3040b021821a8d93aed8d01ba36db6c82372211fed714d9a32607038cdfd565bd529ffc637212aaa2c224ef22b603eccefb5bf1e085c191d4b24fe742b17ab3f55d4e6f05ef
</item>
<!-- name -->
<item>F-Droid Archive</item>
<!-- address -->
@ -38,6 +16,26 @@
<!-- enabled -->
<item>0</item>
<!-- priority -->
<item>1</item>
<!-- push requests -->
<item>ignore</item>
<!-- pubkey -->
<item>
3082035e30820246a00302010202044c49cd00300d06092a864886f70d01010505003071310b300906035504061302554b3110300e06035504081307556e6b6e6f776e3111300f0603550407130857657468657262793110300e060355040a1307556e6b6e6f776e3110300e060355040b1307556e6b6e6f776e311930170603550403131043696172616e2047756c746e69656b73301e170d3130303732333137313032345a170d3337313230383137313032345a3071310b300906035504061302554b3110300e06035504081307556e6b6e6f776e3111300f0603550407130857657468657262793110300e060355040a1307556e6b6e6f776e3110300e060355040b1307556e6b6e6f776e311930170603550403131043696172616e2047756c746e69656b7330820122300d06092a864886f70d01010105000382010f003082010a028201010096d075e47c014e7822c89fd67f795d23203e2a8843f53ba4e6b1bf5f2fd0e225938267cfcae7fbf4fe596346afbaf4070fdb91f66fbcdf2348a3d92430502824f80517b156fab00809bdc8e631bfa9afd42d9045ab5fd6d28d9e140afc1300917b19b7c6c4df4a494cf1f7cb4a63c80d734265d735af9e4f09455f427aa65a53563f87b336ca2c19d244fcbba617ba0b19e56ed34afe0b253ab91e2fdb1271f1b9e3c3232027ed8862a112f0706e234cf236914b939bcf959821ecb2a6c18057e070de3428046d94b175e1d89bd795e535499a091f5bc65a79d539a8d43891ec504058acb28c08393b5718b57600a211e803f4a634e5c57f25b9b8c4422c6fd90203010001300d06092a864886f70d0101050500038201010008e4ef699e9807677ff56753da73efb2390d5ae2c17e4db691d5df7a7b60fc071ae509c5414be7d5da74df2811e83d3668c4a0b1abc84b9fa7d96b4cdf30bba68517ad2a93e233b042972ac0553a4801c9ebe07bf57ebe9a3b3d6d663965260e50f3b8f46db0531761e60340a2bddc3426098397fda54044a17e5244549f9869b460ca5e6e216b6f6a2db0580b480ca2afe6ec6b46eedacfa4aa45038809ece0c5978653d6c85f678e7f5a2156d1bedd8117751e64a4b0dcd140f3040b021821a8d93aed8d01ba36db6c82372211fed714d9a32607038cdfd565bd529ffc637212aaa2c224ef22b603eccefb5bf1e085c191d4b24fe742b17ab3f55d4e6f05ef
</item>
<!-- name -->
<item>F-Droid</item>
<!-- address -->
<item>https://f-droid.org/repo</item>
<!-- description -->
<item>The official F-Droid Free Software repository. Everything in this repository is always built from the source code.
</item>
<!-- version -->
<item>13</item>
<!-- enabled -->
<item>1</item>
<!-- priority -->
<item>2</item>
<!-- push requests -->
<item>ignore</item>
@ -47,13 +45,12 @@
</item>
<!-- name -->
<item>Guardian Project</item>
<item>Guardian Project Archive</item>
<!-- address -->
<item>https://guardianproject.info/fdroid/repo</item>
<item>https://guardianproject.info/fdroid/archive</item>
<!-- description -->
<item>The official app repository of The Guardian Project. Applications in this repository
are official binaries build by the original application developers and signed by the
same key as the APKs that are released in the Google Play store.
<item>The official repository of The Guardian Project apps for use with F-Droid client. This
contains older versions of applications from the main repository.
</item>
<!-- version -->
<item>13</item>
@ -69,12 +66,13 @@
</item>
<!-- name -->
<item>Guardian Project Archive</item>
<item>Guardian Project</item>
<!-- address -->
<item>https://guardianproject.info/fdroid/archive</item>
<item>https://guardianproject.info/fdroid/repo</item>
<!-- description -->
<item>The official repository of The Guardian Project apps for use with F-Droid client. This
contains older versions of applications from the main repository.
<item>The official app repository of The Guardian Project. Applications in this repository
are official binaries build by the original application developers and signed by the
same key as the APKs that are released in the Google Play store.
</item>
<!-- version -->
<item>13</item>