summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
Diffstat (limited to 'Logs')
-rw-r--r--Logs/Location.hs11
-rw-r--r--Logs/Trust.hs5
-rw-r--r--Logs/UUIDBased.hs14
-rw-r--r--Logs/Web.hs2
4 files changed, 15 insertions, 17 deletions
diff --git a/Logs/Location.hs b/Logs/Location.hs
index 8855cf63b..602c46f31 100644
--- a/Logs/Location.hs
+++ b/Logs/Location.hs
@@ -29,16 +29,15 @@ import Logs.Presence
{- Log a change in the presence of a key's value in a repository. -}
logChange :: Git.Repo -> Key -> UUID -> LogStatus -> Annex ()
-logChange repo key u s
- | null u = error $
- "unknown UUID for " ++ Git.repoDescribe repo ++
- " (have you run git annex init there?)"
- | otherwise = addLog (logFile key) =<< logNow s u
+logChange _ key (UUID u) s = addLog (logFile key) =<< logNow s u
+logChange repo _ NoUUID _ = error $
+ "unknown UUID for " ++ Git.repoDescribe repo ++
+ " (have you run git annex init there?)"
{- Returns a list of repository UUIDs that, according to the log, have
- the value of a key. -}
keyLocations :: Key -> Annex [UUID]
-keyLocations = currentLog . logFile
+keyLocations key = map read <$> (currentLog . logFile) key
{- Finds all keys that have location log information.
- (There may be duplicate keys in the list.) -}
diff --git a/Logs/Trust.hs b/Logs/Trust.hs
index 372d8b360..53a1bca2c 100644
--- a/Logs/Trust.hs
+++ b/Logs/Trust.hs
@@ -53,13 +53,12 @@ parseTrust s
{- Changes the trust level for a uuid in the trustLog. -}
trustSet :: UUID -> TrustLevel -> Annex ()
-trustSet uuid level = do
- when (null uuid) $
- error "unknown UUID; cannot modify trust level"
+trustSet uuid@(UUID _) level = do
ts <- liftIO $ getPOSIXTime
Annex.Branch.change trustLog $
showLog show . changeLog ts uuid level . parseLog parseTrust
Annex.changeState $ \s -> s { Annex.trustmap = Nothing }
+trustSet NoUUID _ = error "unknown UUID; cannot modify trust level"
{- Partitions a list of UUIDs to those matching a TrustLevel and not. -}
trustPartition :: TrustLevel -> [UUID] -> Annex ([UUID], [UUID])
diff --git a/Logs/UUIDBased.hs b/Logs/UUIDBased.hs
index 46fa80be0..7184709fe 100644
--- a/Logs/UUIDBased.hs
+++ b/Logs/UUIDBased.hs
@@ -50,9 +50,9 @@ showLog :: (a -> String) -> Log a -> String
showLog shower = unlines . map showpair . M.toList
where
showpair (k, LogEntry (Date p) v) =
- unwords [k, shower v, tskey ++ show p]
+ unwords [show k, shower v, tskey ++ show p]
showpair (k, LogEntry Unknown v) =
- unwords [k, shower v]
+ unwords [show k, shower v]
parseLog :: (String -> Maybe a) -> String -> Log a
parseLog parser = M.fromListWith best . catMaybes . map pair . lines
@@ -61,7 +61,7 @@ parseLog parser = M.fromListWith best . catMaybes . map pair . lines
| null ws = Nothing
| otherwise = case parser $ unwords info of
Nothing -> Nothing
- Just v -> Just (u, LogEntry c v)
+ Just v -> Just (read u, LogEntry c v)
where
ws = words line
u = head ws
@@ -103,8 +103,8 @@ prop_TimeStamp_sane = Unknown < Date 1
prop_addLog_sane :: Bool
prop_addLog_sane = newWins && newestWins
where
- newWins = addLog "foo" (LogEntry (Date 1) "new") l == l2
- newestWins = addLog "foo" (LogEntry (Date 1) "newest") l2 /= l2
+ newWins = addLog (UUID "foo") (LogEntry (Date 1) "new") l == l2
+ newestWins = addLog (UUID "foo") (LogEntry (Date 1) "newest") l2 /= l2
- l = M.fromList [("foo", LogEntry (Date 0) "old")]
- l2 = M.fromList [("foo", LogEntry (Date 1) "new")]
+ l = M.fromList [(UUID "foo", LogEntry (Date 0) "old")]
+ l2 = M.fromList [(UUID "foo", LogEntry (Date 1) "new")]
diff --git a/Logs/Web.hs b/Logs/Web.hs
index 605797079..b52e347e5 100644
--- a/Logs/Web.hs
+++ b/Logs/Web.hs
@@ -21,7 +21,7 @@ type URLString = String
-- Dummy uuid for the whole web. Do not alter.
webUUID :: UUID
-webUUID = "00000000-0000-0000-0000-000000000001"
+webUUID = UUID "00000000-0000-0000-0000-000000000001"
{- The urls for a key are stored in remote/web/hash/key.log
- in the git-annex branch. -}