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:
parent
deff25549a
commit
2da2ae0919
5 changed files with 86 additions and 6 deletions
|
@ -129,6 +129,7 @@ perform key file backend numcopies = do
|
|||
, verifyWorkTree key file
|
||||
, checkKeySize key keystatus ai
|
||||
, checkBackend backend key keystatus afile
|
||||
, checkKeyUpgrade backend key ai afile
|
||||
, checkKeyNumCopies key afile numcopies
|
||||
]
|
||||
where
|
||||
|
@ -409,6 +410,31 @@ checkKeySizeOr bad key file ai = case keySize key of
|
|||
, msg
|
||||
]
|
||||
|
||||
{- Check for keys that are upgradable.
|
||||
-
|
||||
- Warns and suggests the user migrate, but does not migrate itself,
|
||||
- because migration can cause more disk space to be used, and makes
|
||||
- worktree changes that need to be committed.
|
||||
-}
|
||||
checkKeyUpgrade :: Backend -> Key -> ActionItem -> AssociatedFile -> Annex Bool
|
||||
checkKeyUpgrade backend key ai (AssociatedFile (Just file)) =
|
||||
case Types.Backend.canUpgradeKey backend of
|
||||
Just a | a key -> do
|
||||
warning $ concat
|
||||
[ actionItemDesc ai key
|
||||
, ": Can be upgraded to an improved key format. "
|
||||
, "You can do so by running: git annex migrate --backend="
|
||||
, formatKeyVariety (keyVariety key) ++ " "
|
||||
, file
|
||||
]
|
||||
return True
|
||||
_ -> return True
|
||||
checkKeyUpgrade _ _ _ (AssociatedFile Nothing) =
|
||||
-- Don't suggest migrating without a filename, because
|
||||
-- while possible to do, there is no actual benefit from
|
||||
-- doing that in this situation.
|
||||
return True
|
||||
|
||||
{- Runs the backend specific check on a key's content object.
|
||||
-
|
||||
- When a file is unlocked, it may be a hard link to the object,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue