] []
return $ not (null l)
-recordKnownUrl :: ImportFeedDbHandle -> URLString -> IO ()
+recordKnownUrl :: ImportFeedDbHandle -> URLByteString -> IO ()
recordKnownUrl h u = queueDb h $
- void $ insertUniqueFast $ KnownUrls $ SByteString $ encodeBS u
+ void $ insertUniqueFast $ KnownUrls $ SByteString u
recordKnownItemId :: ImportFeedDbHandle -> SByteString -> IO ()
recordKnownItemId h i = queueDb h $
let f = getTopFilePath (DiffTree.file ti)
case extLogFileKey urlLogExt f of
Just k -> do
- knownurls =<< getUrls k
+ knownurls =<< getUrls' k
Nothing -> case extLogFileKey metaDataLogExt f of
Just k -> do
m <- getCurrentMetaData k
{- Web url logs.
-
- - Copyright 2011-2021 Joey Hess <id@joeyh.name>
+ - Copyright 2011-2023 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
module Logs.Web (
URLString,
+ URLByteString,
getUrls,
+ getUrls',
getUrlsWithPrefix,
setUrlPresent,
setUrlMissing,
) where
import qualified Data.Map as M
+import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as L
import Annex.Common
import qualified Annex.Branch
import qualified Types.Remote as Remote
+type URLByteString = S.ByteString
+
{- Gets all urls that a key might be available from. -}
getUrls :: Key -> Annex [URLString]
getUrls key = do
- config <- Annex.getGitConfig
- l <- go $ urlLogFile config key : oldurlLogs config key
+ l <- map decodeBS <$> getUrls' key
tmpl <- Annex.getState (maybeToList . M.lookup key . Annex.tempurls)
return (tmpl ++ l)
+
+{- Note that this does not include temporary urls set with setTempUrl. -}
+getUrls' :: Key -> Annex [URLByteString]
+getUrls' key = do
+ config <- Annex.getGitConfig
+ go $ urlLogFile config key : oldurlLogs config key
where
go [] = return []
go (l:ls) = do
us <- currentLogInfo l
if null us
then go ls
- else return $ map decodeUrlLogInfo us
+ else return $ map fromLogInfo us
getUrlsWithPrefix :: Key -> String -> Annex [URLString]
getUrlsWithPrefix key prefix = filter (prefix `isPrefixOf`)
("", u') -> (u', OtherDownloader)
_ -> (u, WebDownloader)
-decodeUrlLogInfo :: LogInfo -> URLString
-decodeUrlLogInfo = decodeBS . fromLogInfo
-
{- Parses the content of an url log file, returning the urls that are
- currently recorded. -}
-parseUrlLog :: L.ByteString -> [URLString]
-parseUrlLog = map decodeUrlLogInfo . getLog
+parseUrlLog :: L.ByteString -> [URLByteString]
+parseUrlLog = map fromLogInfo . getLog