diff options
author | Joey Hess <joey@kitenet.net> | 2012-07-05 16:24:02 -0600 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-07-05 16:24:02 -0600 |
commit | 5a753a7b8a46c7326b6431dcf5a6eb755534e80d (patch) | |
tree | b99820c9fa13b8e8e272d049ffb220860d2d684d | |
parent | 25701717eb0a9d3e6da5f806ef441a15aaacbc39 (diff) |
SHAnE backends are now smarter about composite extensions, such as .tar.gz Closes: #680450
-rw-r--r-- | Backend/SHA.hs | 17 | ||||
-rw-r--r-- | debian/changelog | 2 |
2 files changed, 11 insertions, 8 deletions
diff --git a/Backend/SHA.hs b/Backend/SHA.hs index 7abbf8035..95ce4a770 100644 --- a/Backend/SHA.hs +++ b/Backend/SHA.hs @@ -97,16 +97,17 @@ keyValueE :: SHASize -> KeySource -> Annex (Maybe Key) keyValueE size source = keyValue size source >>= maybe (return Nothing) addE where addE k = return $ Just $ k - { keyName = keyName k ++ extension + { keyName = keyName k ++ selectExtension (keyFilename source) , keyBackendName = shaNameE size } - naiveextension = takeExtension $ keyFilename source - extension - -- long or newline containing extensions are - -- probably not really an extension - | length naiveextension > 6 || - '\n' `elem` naiveextension = "" - | otherwise = naiveextension + +selectExtension :: FilePath -> String +selectExtension = join "." . reverse . take 2 . takeWhile shortenough . + reverse . split "." . takeExtensions + where + shortenough e + | '\n' `elem` e = False -- newline in extension?! + | otherwise = length e <= 4 -- long enough for "jpeg" {- A key's checksum is checked during fsck. -} checkKeyChecksum :: SHASize -> Key -> FilePath -> Annex Bool diff --git a/debian/changelog b/debian/changelog index 1c44f5952..5eaf9d52e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ git-annex (3.20120630) UNRELEASED; urgency=low but avoids portability problems. * Use SHA library for files less than 50 kb in size, at which point it's faster than forking the more optimised external program. + * SHAnE backends are now smarter about composite extensions, such as + .tar.gz Closes: #680450 -- Joey Hess <joeyh@debian.org> Sun, 01 Jul 2012 15:04:37 -0400 |