summaryrefslogtreecommitdiff
path: root/Command/Migrate.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-12-20 15:43:14 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-12-20 17:07:10 -0400
commit836c6429cc1db7212a5a391ea0a03326fc1edbd9 (patch)
tree9fc304c0acc2d62d24add6703db2119ae9aea98a /Command/Migrate.hs
parent0aedef26424c2e17a2cfc0bb24ec52bddc560bf0 (diff)
handle sha*sum's leading \ in checksum with certian unsual filenames
* Bugfix: Remove leading \ from checksums output by sha*sum commands, when the filename contains \ or a newline. Closes: #696384 * fsck: Still accept checksums with a leading \ as valid, now that above bug is fixed. * migrate: Remove leading \ in checksums
Diffstat (limited to 'Command/Migrate.hs')
-rw-r--r--Command/Migrate.hs18
1 files changed, 13 insertions, 5 deletions
diff --git a/Command/Migrate.hs b/Command/Migrate.hs
index 0b23c2a40..d486eeb09 100644
--- a/Command/Migrate.hs
+++ b/Command/Migrate.hs
@@ -11,6 +11,7 @@ import Common.Annex
import Command
import Backend
import qualified Types.Key
+import qualified Types.Backend
import Types.KeySource
import Annex.Content
import qualified Command.ReKey
@@ -26,7 +27,7 @@ start :: FilePath -> (Key, Backend) -> CommandStart
start file (key, oldbackend) = do
exists <- inAnnex key
newbackend <- choosebackend =<< chooseBackend file
- if (newbackend /= oldbackend || upgradableKey key) && exists
+ if (newbackend /= oldbackend || upgradableKey oldbackend key) && exists
then do
showStart "migrate" file
next $ perform file key oldbackend newbackend
@@ -35,10 +36,17 @@ start file (key, oldbackend) = do
choosebackend Nothing = Prelude.head <$> orderedList
choosebackend (Just backend) = return backend
-{- Checks if a key is upgradable to a newer representation. -}
-{- Ideally, all keys have file size metadata. Old keys may not. -}
-upgradableKey :: Key -> Bool
-upgradableKey key = isNothing $ Types.Key.keySize key
+{- Checks if a key is upgradable to a newer representation.
+ -
+ - Reasons for migration:
+ - - Ideally, all keys have file size metadata. Old keys may not.
+ - - Something has changed in the backend, such as a bug fix.
+ -}
+upgradableKey :: Backend -> Key -> Bool
+upgradableKey backend key = isNothing (Types.Key.keySize key) || backendupgradable
+ where
+ backendupgradable = maybe False (\a -> a key)
+ (Types.Backend.canUpgradeKey backend)
{- Store the old backend's key in the new backend
- The old backend's key is not dropped from it, because there may