support building with old version of bytestring

This commit is contained in:
Joey Hess 2025-03-14 14:44:22 -04:00
parent 3dd41909dd
commit de6e9f5beb
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -6,6 +6,7 @@
-} -}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE CPP #-}
module Annex.Locations ( module Annex.Locations (
keyFile, keyFile,
@ -744,7 +745,7 @@ reSanitizeKeyName = preSanitizeKeyName' True
keyFile :: Key -> OsPath keyFile :: Key -> OsPath
keyFile k = keyFile k =
let b = serializeKey'' k let b = serializeKey'' k
in toOsPath $ if SB.any (`elem` needesc) b in toOsPath $ if anyneedesc b
then mconcat $ map esc (SB.unpack b) then mconcat $ map esc (SB.unpack b)
else b else b
where where
@ -757,6 +758,12 @@ keyFile k =
needesc = map (fromIntegral . ord) ['&', '%', ':', '/'] needesc = map (fromIntegral . ord) ['&', '%', ':', '/']
#if MIN_VERSION_bytestring(0,11,3)
anyneedesc = SB.any (`elem` needesc)
#else
anyneedesc = any (`elem` needesc) . SB.unpack
#endif
{- Reverses keyFile, converting a filename fragment (ie, the basename of {- Reverses keyFile, converting a filename fragment (ie, the basename of
- the symlink target) into a key. -} - the symlink target) into a key. -}
fileKey :: OsPath -> Maybe Key fileKey :: OsPath -> Maybe Key