summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
Diffstat (limited to 'Logs')
-rw-r--r--Logs/Location.hs4
-rw-r--r--Logs/Remote.hs5
-rw-r--r--Logs/Trust.hs14
-rw-r--r--Logs/UUID.hs4
-rw-r--r--Logs/UUIDBased.hs10
5 files changed, 17 insertions, 20 deletions
diff --git a/Logs/Location.hs b/Logs/Location.hs
index 27b4d709e..588962bc5 100644
--- a/Logs/Location.hs
+++ b/Logs/Location.hs
@@ -68,7 +68,7 @@ logFile key = hashDirLower key ++ keyFile key ++ ".log"
{- Converts a log filename into a key. -}
logFileKey :: FilePath -> Maybe Key
logFileKey file
- | end == ".log" = fileKey beginning
+ | ext == ".log" = fileKey base
| otherwise = Nothing
where
- (beginning, end) = splitAt (length file - 4) file
+ (base, ext) = splitAt (length file - 4) file
diff --git a/Logs/Remote.hs b/Logs/Remote.hs
index 8d15f3151..d9b41d8c4 100644
--- a/Logs/Remote.hs
+++ b/Logs/Remote.hs
@@ -73,14 +73,13 @@ configUnEscape = unescape
| c == '&' = entity rest
| otherwise = c : unescape rest
entity s = if ok
- then chr (read num) : unescape rest
+ then chr (Prelude.read num) : unescape rest
else '&' : unescape s
where
num = takeWhile isNumber s
r = drop (length num) s
rest = drop 1 r
- ok = not (null num) &&
- not (null r) && head r == ';'
+ ok = not (null num) && take 1 r == ";"
{- for quickcheck -}
prop_idempotent_configEscape :: String -> Bool
diff --git a/Logs/Trust.hs b/Logs/Trust.hs
index 196666a84..5d769bd24 100644
--- a/Logs/Trust.hs
+++ b/Logs/Trust.hs
@@ -54,18 +54,16 @@ trustMap = do
Just m -> return m
Nothing -> do
overrides <- M.fromList <$> Annex.getState Annex.forcetrust
- m <- (M.union overrides . simpleMap . parseLog parseTrust) <$>
+ m <- (M.union overrides . simpleMap . parseLog (Just . parseTrust)) <$>
Annex.Branch.get trustLog
Annex.changeState $ \s -> s { Annex.trustmap = Just m }
return m
-parseTrust :: String -> Maybe TrustLevel
-parseTrust s
- | length w > 0 = Just $ parse $ head w
- -- back-compat; the trust.log used to only list trusted repos
- | otherwise = Just Trusted
+{- The trust.log used to only list trusted repos, without a field for the
+ - trust status, which is why this defaults to Trusted. -}
+parseTrust :: String -> TrustLevel
+parseTrust s = maybe Trusted parse $ headMaybe $ words s
where
- w = words s
parse "1" = Trusted
parse "0" = UnTrusted
parse "X" = DeadTrusted
@@ -82,6 +80,6 @@ trustSet :: UUID -> TrustLevel -> Annex ()
trustSet uuid@(UUID _) level = do
ts <- liftIO getPOSIXTime
Annex.Branch.change trustLog $
- showLog showTrust . changeLog ts uuid level . parseLog parseTrust
+ showLog showTrust . changeLog ts uuid level . parseLog (Just . parseTrust)
Annex.changeState $ \s -> s { Annex.trustmap = Nothing }
trustSet NoUUID _ = error "unknown UUID; cannot modify trust level"
diff --git a/Logs/UUID.hs b/Logs/UUID.hs
index b325c78b6..18cbee61e 100644
--- a/Logs/UUID.hs
+++ b/Logs/UUID.hs
@@ -57,9 +57,9 @@ fixBadUUID = M.fromList . map fixup . M.toList
kuuid = fromUUID k
isbad = not (isuuid kuuid) && isuuid lastword
ws = words $ value v
- lastword = last ws
+ lastword = Prelude.last ws
fixeduuid = toUUID lastword
- fixedvalue = unwords $ kuuid: init ws
+ fixedvalue = unwords $ kuuid: Prelude.init ws
-- For the fixed line to take precidence, it should be
-- slightly newer, but only slightly.
newertime (LogEntry (Date d) _) = d + minimumPOSIXTimeSlice
diff --git a/Logs/UUIDBased.hs b/Logs/UUIDBased.hs
index 04b12887d..b09d93f90 100644
--- a/Logs/UUIDBased.hs
+++ b/Logs/UUIDBased.hs
@@ -64,15 +64,15 @@ parseLog parser = M.fromListWith best . mapMaybe parse . lines
where
makepair v = Just (toUUID u, LogEntry ts v)
ws = words line
- u = head ws
- end = last ws
+ u = Prelude.head ws
+ t = Prelude.last ws
ts
- | tskey `isPrefixOf` end =
- pdate $ tail $ dropWhile (/= '=') end
+ | tskey `isPrefixOf` t =
+ pdate $ drop 1 $ dropWhile (/= '=') t
| otherwise = Unknown
info
| ts == Unknown = drop 1 ws
- | otherwise = drop 1 $ init ws
+ | otherwise = drop 1 $ beginning ws
pdate s = case parseTime defaultTimeLocale "%s%Qs" s of
Nothing -> Unknown
Just d -> Date $ utcTimeToPOSIXSeconds d