Skip to content

Fix #263 "cannot manually add repo that was swapped before"

Pretends that the swap repo never existed, by deleting it before adding the new repo, and showing the same message that is shown when a new repo is added. This does not change behaviour for existing non-swap repos. They are not deleted before being added again, or else we would lose the ability to verify the fingerprint of an existing repo is the same as a newly added one with the same URL.

Note that this has the effect that the fingerprint/pubkey of the swap repo is nuked when adding that repo manually.

Internationalised the string "BAD FINGERPRINT" while I was at it.

To test it out, here is some instructions to make life easier:

Firstly, go into manage repos and delete the guardian project main repo (going to pretend to use this for swapping to make life easier).

Then if you run sqlite3 /data/data/org.fdroid.fdroid/databases/fdroid and execute the query:

select substr(fingerprint, 0, 10), substr(pubkey, 70, 10), address, isSwap from fdroid_repo order by fingerprint desc;

You should see:

B7C2EEFD8|081ad310b3|https://guardianproject.info/fdroid/archive|0
43238D512|071310b300|https://f-droid.org/archive|0
43238D512|071310b300|https://f-droid.org/repo/|0

Now simulate a swap session like so:

adb shell am start -a android.intent.action.VIEW -d 'https://guardianproject.info/fdroid/repo?swap=1'

Which results in the following database:

B7C2EEFD8|081ad310b3|https://guardianproject.info/fdroid/archive|0
B7C2EEFD8|081ad310b3|https://guardianproject.info/fdroid/repo|1
43238D512|071310b300|https://f-droid.org/archive|0
43238D512|071310b300|https://f-droid.org/repo/|0

Note the last column (isSwap) is 1 for the newly added swap repo. Now we will add the repo (without a fingerprint) to the Manage Repo activity. If you are feeling lazy, execute:

adb shell am start -a android.intent.action.VIEW -d https://guardianproject.info/fdroid/repo

The repo will be removed, then re-added as a TOFU repo:

B7C2EEFD8|081ad310b3|https://guardianproject.info/fdroid/archive|0
43238D512|071310b300|https://f-droid.org/archive|0
43238D512|071310b300|https://f-droid.org/repo/|0
||https://guardianproject.info/fdroid/repo/|0

I noticed some bugginess with sending the same intent and it being ignored, I'll have to look at this another day (not caused by this change, it already existed in master).

Merge request reports