diff options
Diffstat (limited to 'Backend')
-rw-r--r-- | Backend/SHA.hs | 16 | ||||
-rw-r--r-- | Backend/URL.hs | 1 | ||||
-rw-r--r-- | Backend/WORM.hs | 1 |
3 files changed, 17 insertions, 1 deletions
diff --git a/Backend/SHA.hs b/Backend/SHA.hs index ef0e92d20..1a278068e 100644 --- a/Backend/SHA.hs +++ b/Backend/SHA.hs @@ -34,6 +34,7 @@ genBackend size = Just $ Backend { name = shaName size , getKey = keyValue size , fsckKey = Just $ checkKeyChecksum size + , canUpgradeKey = Just $ needsUpgrade } genBackendE :: SHASize -> Maybe Backend @@ -61,6 +62,8 @@ shaN shasize file filesize = do parse command [] = bad command parse command (l:_) | null sha = bad command + -- sha is prefixed with \ when filename contains certian chars + | "\\" `isPrefixOf` sha = drop 1 sha | otherwise = sha where sha = fst $ separate (== ' ') l @@ -137,6 +140,17 @@ checkKeyChecksum size key file = do check <$> shaN size file filesize _ -> return True where + sha = keySha key check s - | s == dropExtensions (keyName key) = True + | s == sha = True + {- A bug caused checksums to be prefixed with \ in some + - cases; still accept these as legal now that the bug has been + - fixed. -} + | '\\' : s == sha = True | otherwise = False + +keySha :: Key -> String +keySha key = dropExtensions (keyName key) + +needsUpgrade :: Key -> Bool +needsUpgrade key = "\\" `isPrefixOf` keySha key diff --git a/Backend/URL.hs b/Backend/URL.hs index 81c287cfd..9e1652970 100644 --- a/Backend/URL.hs +++ b/Backend/URL.hs @@ -24,6 +24,7 @@ backend = Backend { name = "URL" , getKey = const $ return Nothing , fsckKey = Nothing + , canUpgradeKey = Nothing } fromUrl :: String -> Maybe Integer -> Key diff --git a/Backend/WORM.hs b/Backend/WORM.hs index 523203713..3471eedc1 100644 --- a/Backend/WORM.hs +++ b/Backend/WORM.hs @@ -20,6 +20,7 @@ backend = Backend { name = "WORM" , getKey = keyValue , fsckKey = Nothing + , canUpgradeKey = Nothing } {- The key includes the file size, modification time, and the |