Add skeleton of database upgrade code to fix the mess caused by issue 0006085
Add draft of database upgrade code for version 3:
- Delete any duplicate OwnIdentity objects created by the restoreOwnIdentity bug https://bugs.freenetproject.org/view.php?id=6085
- Restore the OwnIdentitys afterwards
- NOT ready for deployment yet: It will throw NPE because there is no IdentityFetcher yet when we call upgradeDB(). This will require the following issue to be fixed first: https://bugs.freenetproject.org/view.php?id=6004
Only execute IdentityFetcher commands after start() has been called:
- Also delete the existing fetcher commands in start(), not in the constructor: To ensure that no duplicate fetches are done in the loop which starts fetching all identities at startup of WOT, we need to delete all existing fetch command en-bloc with the loop. Further, doing database stuff in constructors is ugly anyway.
- Fixes issue https://bugs.freenetproject.org/view.php?id=6004
Do NOT call finishTrustListImport for EVERY identity:
- Only call it if a duplicate existed.
- Do that for the whole code block which deals with duplicates.
Don't just pretend to take the locks, take them actually:
- restoreOwnIdentity() will do it anyway.
- This will make the function a better capsule because it makes less assumptions about the outer state of WOT.
Add restoreOwnIdentityWithoutCommit() and use it in the database upgrade code:
- Previously restoreOwnIdentity() did its own transaction. This meant that the database upgrade transaction could not be fully rolled back in all cases.
Fix NPE in IdentityFetcher:
- It needs the RequestClient so we have to create it earlier
Merge branch 'master' into issue-6085-database-cleanup
Fix wrong SFS entry "Identities.Amount":
- This is the most recent style of specifying the amount. The "Amount" without prefix is legacy.
- addIdentityFields() sets this to 1 already, so it is important that we set it to the correct value.
Merge branch 'master' into issue-6085-database-cleanup