fix migration bug and make fsck warn

* migrate: Fix bug in migration between eg SHA256 and SHA256E,
  that caused the extension to be included in SHA256 keys,
  and omitted from SHA256E keys.
  (Bug introduced in version 6.20170214)
* migrate: Check for above bug when migrating from SHA256 to SHA256
  (and same for SHA1 to SHA1 etc), and remove the extension that should
  not be in the SHA256 key.
* fsck: Detect and warn when keys need an upgrade, either to fix up
  from the above migrate bug, or to add missing size information
  (a long ago transition), or because of a few other past key related
  bugs.

This commit was sponsored by Henrik Riomar on Patreon.
This commit is contained in:
Joey Hess 2018-05-23 14:07:51 -04:00
parent deff25549a
commit 2da2ae0919
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 86 additions and 6 deletions

View file

@ -46,3 +46,4 @@ lrwxrwxrwx 1 grawity grawity 201 May 22 08:17 EN_EXCH2003_ENT.ISO -> ../../../.g
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
> [[fixed|done]] --[[Joey]]

View file

@ -0,0 +1,27 @@
[[!comment format=mdwn
username="joey"
subject="""comment 2"""
date="2018-05-23T17:18:35Z"
content="""
The bug was that it got the test backwards for whether
it was supposed to be adding or removing the extension!
Bug was introduced in [[!commit 9c4650358ca85a298b747bb897dbf4f8f891fa22]]
over a year ago.
The bogus SHA256 key with an extension tacked on at the end
passes fsck because the code happens to always strip extensions from
hashes, even if the key type is not supposed to include an extension.
Fixed the bug. But this leaves the potential for these badly formed
SHA256 keys with an extension on the end being in a repository and
needing to keep code working for them. (The SHA256E keys without an
extension that also result from the bug are technically not badly formed.)
So, I also made migrate fix those badly formed keys. You have to specify
--backend=SHA256, and then it will migrate the badly formed SHA256 key to
a correctly formed SHA256 key.
Also, git-annex fsck will now warn when it detects a key needing such a
migration.
"""]]