diff options
Diffstat (limited to 'Logs')
-rw-r--r-- | Logs/MapLog.hs | 7 | ||||
-rw-r--r-- | Logs/Presence/Pure.hs | 5 | ||||
-rw-r--r-- | Logs/SingleValue.hs | 5 | ||||
-rw-r--r-- | Logs/Transfer.hs | 7 | ||||
-rw-r--r-- | Logs/Transitions.hs | 8 | ||||
-rw-r--r-- | Logs/UUIDBased.hs | 7 | ||||
-rw-r--r-- | Logs/Unused.hs | 4 |
7 files changed, 18 insertions, 25 deletions
diff --git a/Logs/MapLog.hs b/Logs/MapLog.hs index 3c7eef26b..d5bb67f68 100644 --- a/Logs/MapLog.hs +++ b/Logs/MapLog.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + {- git-annex Map log - - This is used to store a Map, in a way that can be union merged. @@ -13,10 +15,9 @@ module Logs.MapLog where import qualified Data.Map as M import Data.Time.Clock.POSIX -import Data.Time -import System.Locale import Common +import Logs.TimeStamp data TimeStamp = Unknown | Date POSIXTime deriving (Eq, Ord, Show) @@ -42,7 +43,7 @@ parseMapLog fieldparser valueparser = M.fromListWith best . mapMaybe parse . lin parse line = do let (ts, rest) = splitword line (sf, sv) = splitword rest - date <- Date . utcTimeToPOSIXSeconds <$> parseTime defaultTimeLocale "%s%Qs" ts + date <- Date <$> parsePOSIXTime ts f <- fieldparser sf v <- valueparser sv Just (f, LogEntry date v) diff --git a/Logs/Presence/Pure.hs b/Logs/Presence/Pure.hs index 88f18435f..ec4415aad 100644 --- a/Logs/Presence/Pure.hs +++ b/Logs/Presence/Pure.hs @@ -8,11 +8,10 @@ module Logs.Presence.Pure where import Data.Time.Clock.POSIX -import Data.Time -import System.Locale import qualified Data.Map as M import Common.Annex +import Logs.TimeStamp import Utility.QuickCheck data LogLine = LogLine { @@ -29,7 +28,7 @@ parseLog :: String -> [LogLine] parseLog = mapMaybe parseline . lines where parseline l = LogLine - <$> (utcTimeToPOSIXSeconds <$> parseTime defaultTimeLocale "%s%Qs" d) + <$> parsePOSIXTime d <*> parseStatus s <*> pure rest where diff --git a/Logs/SingleValue.hs b/Logs/SingleValue.hs index dbbe996f3..213bcd217 100644 --- a/Logs/SingleValue.hs +++ b/Logs/SingleValue.hs @@ -15,11 +15,10 @@ module Logs.SingleValue where import Common.Annex import qualified Annex.Branch +import Logs.TimeStamp import qualified Data.Set as S import Data.Time.Clock.POSIX -import Data.Time -import System.Locale class SingleValueSerializable v where serialize :: v -> String @@ -42,7 +41,7 @@ parseLog = S.fromList . mapMaybe parse . lines where parse line = do let (ts, s) = splitword line - date <- utcTimeToPOSIXSeconds <$> parseTime defaultTimeLocale "%s%Qs" ts + date <- parsePOSIXTime ts v <- deserialize s Just (LogEntry date v) splitword = separate (== ' ') diff --git a/Logs/Transfer.hs b/Logs/Transfer.hs index 5b5b8f8cb..078157208 100644 --- a/Logs/Transfer.hs +++ b/Logs/Transfer.hs @@ -18,11 +18,10 @@ import Utility.Percentage import Utility.QuickCheck import Utility.PID import Utility.LockFile +import Logs.TimeStamp import Data.Time.Clock import Data.Time.Clock.POSIX -import Data.Time -import System.Locale import Control.Concurrent {- Enough information to uniquely identify a transfer, used as the filename @@ -276,10 +275,6 @@ readTransferInfo mpid s = TransferInfo then Just <$> readish =<< headMaybe (drop 1 bits) else pure Nothing -- not failure -parsePOSIXTime :: String -> Maybe POSIXTime -parsePOSIXTime s = utcTimeToPOSIXSeconds - <$> parseTime defaultTimeLocale "%s%Qs" s - {- The directory holding transfer information files for a given Direction. -} transferDir :: Direction -> Git.Repo -> FilePath transferDir direction r = gitAnnexTransferDir r </> showLcDirection direction diff --git a/Logs/Transitions.hs b/Logs/Transitions.hs index d782455a6..5ccfd7e8c 100644 --- a/Logs/Transitions.hs +++ b/Logs/Transitions.hs @@ -15,11 +15,10 @@ module Logs.Transitions where import Data.Time.Clock.POSIX -import Data.Time -import System.Locale import qualified Data.Set as S import Common.Annex +import Logs.TimeStamp transitionsLog :: FilePath transitionsLog = "transitions.log" @@ -66,12 +65,13 @@ showTransitionLine :: TransitionLine -> String showTransitionLine (TransitionLine ts t) = unwords [show t, show ts] parseTransitionLine :: String -> Maybe TransitionLine -parseTransitionLine s = TransitionLine <$> pdate ds <*> readish ts +parseTransitionLine s = TransitionLine + <$> parsePOSIXTime ds + <*> readish ts where ws = words s ts = Prelude.head ws ds = unwords $ Prelude.tail ws - pdate = utcTimeToPOSIXSeconds <$$> parseTime defaultTimeLocale "%s%Qs" combineTransitions :: [Transitions] -> Transitions combineTransitions = S.unions diff --git a/Logs/UUIDBased.hs b/Logs/UUIDBased.hs index ac876e65f..5613c6fb4 100644 --- a/Logs/UUIDBased.hs +++ b/Logs/UUIDBased.hs @@ -30,12 +30,11 @@ module Logs.UUIDBased ( import qualified Data.Map as M import Data.Time.Clock.POSIX -import Data.Time -import System.Locale import Common import Types.UUID import Logs.MapLog +import Logs.TimeStamp type Log v = MapLog UUID v @@ -73,9 +72,9 @@ parseLogWithUUID parser = M.fromListWith best . mapMaybe parse . lines info | ts == Unknown = drop 1 ws | otherwise = drop 1 $ beginning ws - pdate s = case parseTime defaultTimeLocale "%s%Qs" s of + pdate s = case parsePOSIXTime s of Nothing -> Unknown - Just d -> Date $ utcTimeToPOSIXSeconds d + Just d -> Date d showLogNew :: (v -> String) -> Log v -> String showLogNew = showMapLog fromUUID diff --git a/Logs/Unused.hs b/Logs/Unused.hs index 883ab8c5b..7a12f186c 100644 --- a/Logs/Unused.hs +++ b/Logs/Unused.hs @@ -32,12 +32,12 @@ import qualified Data.Map as M import qualified Data.Set as S import Data.Time.Clock.POSIX import Data.Time -import System.Locale import Common.Annex import qualified Annex import Types.Key import Utility.Tmp +import Logs.TimeStamp -- everything that is stored in the unused log type UnusedLog = M.Map Key (Int, Maybe POSIXTime) @@ -81,7 +81,7 @@ readUnusedLog prefix = do , return M.empty ) where - parse line = case (readish sint, file2key skey, utcTimeToPOSIXSeconds <$> parseTime defaultTimeLocale "%s%Qs" ts) of + parse line = case (readish sint, file2key skey, parsePOSIXTime ts) of (Just int, Just key, mtimestamp) -> Just (key, (int, mtimestamp)) _ -> Nothing where |