fix parsing of startedTime

This commit is contained in:
Joey Hess 2012-07-18 20:48:08 -04:00
parent 2edb5d145c
commit 549f861999

View file

@ -118,7 +118,7 @@ checkTransfer t = do
case locked of case locked of
Nothing -> return Nothing Nothing -> return Nothing
Just (pid, _) -> liftIO $ Just (pid, _) -> liftIO $
flip catchDefaultIO Nothing $ flip catchDefaultIO Nothing $ do
readTransferInfo pid readTransferInfo pid
<$> readFile tfile <$> readFile tfile
@ -163,7 +163,7 @@ writeTransferInfo :: TransferInfo -> String
writeTransferInfo info = unlines writeTransferInfo info = unlines
-- transferPid is not included; instead obtained by looking at -- transferPid is not included; instead obtained by looking at
-- the process that locks the file. -- the process that locks the file.
[ show $ startedTime info [ maybe "" show $ startedTime info
-- bytesComplete is not included; changes too fast -- bytesComplete is not included; changes too fast
, fromMaybe "" $ associatedFile info -- comes last; arbitrary content , fromMaybe "" $ associatedFile info -- comes last; arbitrary content
] ]
@ -172,7 +172,7 @@ readTransferInfo :: ProcessID -> String -> Maybe TransferInfo
readTransferInfo pid s = readTransferInfo pid s =
case bits of case bits of
[time] -> TransferInfo [time] -> TransferInfo
<$> parsetime time <$> (Just <$> parsePOSIXTime time)
<*> pure (Just pid) <*> pure (Just pid)
<*> pure Nothing <*> pure Nothing
<*> pure Nothing <*> pure Nothing
@ -182,5 +182,7 @@ readTransferInfo pid s =
where where
(bits, filebits) = splitAt 1 $ lines s (bits, filebits) = splitAt 1 $ lines s
filename = join "\n" filebits filename = join "\n" filebits
parsetime t = Just . utcTimeToPOSIXSeconds
<$> parseTime defaultTimeLocale "%s%Qs" t parsePOSIXTime :: String -> Maybe POSIXTime
parsePOSIXTime s = utcTimeToPOSIXSeconds
<$> parseTime defaultTimeLocale "%s%Qs" s